Execute Code After A Data Connection Refresh Is Finished |
Execute Code After A Data Connection Refresh Is Finished - Excel |
|
I have a piece of code called ConvertDates that formats data contained on 6 worksheets. The 6 data sheets all contain a data connection to a website of foreign exchange tables.
What I want is for my code to execute as soon as the data connection refresh has finished.
When I use the statement
Code:
ActiveWorkbook.RefreshAll Application.Run "Project1.xlsm!ConvertDates"
The code executes the macro whilst the refresh is still happening, thereby screwing up my results. I don't really want to use a timed wait, because the refresh speed is going to vary from user to user.
Is there some way I can tell excel to wait till the refresh has finished and then execute the code?
Any help would be hugely appreciated.
Similar Topics
Any help is appreciated. Here is an excerpt of the code:
Workbooks.Open Filename:="C:\Profile.xls"
Sheets("SELECTION").Select
Range("F3").Value = SNR
' THIS PART ONLY WORKS IF YOU STEP THROUGH THE MACRO USING THE DEBUGGER...IF YOU RUN MACRO NORMALLY THE CONNECTIONS DO NOT REFRESH
ActiveWorkbook.Connections("Connection").Refresh
ActiveWorkbook.Connections("Connection14").Refresh
ActiveWorkbook.Connections("Query from C_Profile").Refresh
ActiveWorkbook.Connections("Query from C_Profile1").Refresh
I have written some code that when a button is selected will Refresh a Data Query Table and all of it's information. However, I seem to be getting issues, can some one point me in the right direction with the code?
Code:
.Sheets("Sheet 1").ListObject.QueryTable.Refresh BackgroundQuery:=False
When I recorded myslef doing this process it looked like this:
Code:
Sheets("Sheet 1").Select Range("D70872").Select Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Many thanks!
button in the excel sheet to update the sheet without doing right click and
refresh.
My user here are very dummies.
I would like to have a help in programming the code for Auto refresh every 5 seconds or so in the excel sheet attached.
The file is Downloaded from one of the sites.
Need to modify with adding a code of auto refreshing every 5 seconds instead of default 1 minutes.
Thanks
Pritz
I have set up a workbook that is sent out to lots of different users. They each keep and use their own copy.
I have set it up so that everything looks OK and is visible on MY screen, but I'm conscious that some users may have different screen sizes, different toolbars set up, and so on, which might make some parts not immediately visible to them.
I have set up an auto-execute macro which automatically sets the zoom factor to best fit, for several of the worksheets, and this works fine.
Here's the code that does it.
Code:
Sheets("WELCOME").Select Range("A1:N18").Select ActiveWindow.Zoom = True
By repeating this code for each worksheet, I can make each one be zoomed just right.
However, the file contains 8 sheets that are all identically laid out, except the number of rows is different.
What I want to do is go to the worksheet that has the largest number of rows (it's always the same worksheet, so I know which one it is), set the zoom factor for THAT worksheet (which I can do, and it always has the same number of rows), and then take THAT zoom factor, whatever it is - and it will vary depending on the user - and apply that to the other worksheets that have a similar layout.
I could just go through each worksheet and zoom it automatically, but that would mean that some of the sheets looked very large, others very small, and I'd like them to have a consistent appearance.
I could also specify a range on each worksheet that was similar to the appropriate range on the longest worksheet, and zoom that automatically, but that's not ideal either, because some of the row heights vary from sheet to sheet, and again I'll end up with different font sizes.
Anyone know how to do this ?
Here is my situation. I have been trying to learn macros but have not made one yet. Need your help. Here at work, I have some incompentant computer workers who claim they KNOW MS sooo well and have certificates etc... *COUGH COUGH* ya ok... LMAO
We have a "shared" work book we all work in. It's nothing fancy, just use it as a PO Book but since it is shared some people continue to not save before they add in more work so that they see a "refreshed" copy of the workbook before they start writing in cells that already contain information.
How to I create a macro button at the top of the page that is literally a SAVE button.. instead of them saving by going to File - Save or cntrl+s ??? I just thought that MAYBE having a big button in their face will remind them.
Secondly as back up I was wondering if you can create a macro to do a refresh of everyones screens automatically - say every 2 or 5 mins??? I don't mean a save... but a refresh so the screen actually updates in front of you. (although I will keep this little piece of magic out of their knowledge so they don't rely on it, just though it would be a secondary back up to helping eliminate these mishaps cause we are loosing alot of information by people saving overtop of other peoples work and not caring.)
Thanks so much!!!!! Muchly appriciated.
I am using below code to Select the Visible rows in the target range:
Code:
Range("A:p").SpecialCells(xlCellTypeVisible).Select
Problems in this code a
1) after applying the filter, while selecting the data it is selecting all the rows in given range till last row on the workbook. I need this to select the the data only till the last used row in the given range.
2) It is not possible to provide the address of the first row after we apply the filter since the first row address may change depending on the values in the table.
E.g. 1st time when I am running the macro the first row in the visible filtered data is starting at Cell address A4 and next time when I will run the macro it may be A6
3) The Code is also selecting the 1st row which is a header row. How can we exclude it from selection.
Some one please revert with the solution.
Thanks in advance.
i've got the following problem:
I want users to double-click on a row on a protected sheet and then do some code based on the row-number of the clicked cell. I've protected the sheet because it contains a lot of formula's.
When a user double-clicks a row it triggers the code through the Workbook_SheetBeforeDoubleClick event.
After the code is executed Excel shows a message that the cell that was clicked was protected etc etc.
How can I prevent this message from popping up?
I've already tried
Code:
application.displaywarnings = false
but that didn't work
Thanks
How can I reset where Excel thinks the end of may data is?
When I press Ctrl+End it highlishts column ANC when really my data now finished at Column AC
thanks
Im using :
'wait until the page loads
Do While ie.Busy Or ie.readyState READYSTATE_COMPLETE
DoEvents
Loop
This doesnt seem to work well enough, since actions are occuring that should NOT occur until the browser is ready.
Any other ideas as to how to make IE wait until the page is completely ready? I wondered about possibly checking the .innerHTML to verify that a unique page element is present.
Thanks,
Scott
I have been tasked with introducing userforms into an excel sheet and tbh I'm quite amazed that excel has this capability of adding userforms to excel sheets.
Anyway, I have 2 columns of data in an excel sheet and I wish to add this to a userform so that the userform displays the 2 columns beside each other with headings, like a table. The user should then be able to select a particular row and insert it into the specified cell.
I would also like the user to select a row on the table and then be able to bring up another table depending on the row selected...basically so that the user can draw deeper into the information that they require.
I have an example excel sheet where I have 2 sheets. One sheet is the user entry sheet called User Entry Screen. the next sheet is the tables sheet where my tables are held. Once the user selects the cell shown in the example sheet, it should then bring up the user form. the user then, depending on which item clicked, then gets shown the next window with a table and info on it. then user should then be able to select an item and the cells on the user entry screen would then get populated.
Personally I think this is a really tricky challenge and any help with doing this would be extremely appreciated.
I'll post up further comments as I am trying to work my way through it!
Thanks,
Jag
I need the necessity do delete a sequence of sheets in my workbook.
If I use this code:
With ActiveWorkbook
If .Worksheets.Count >= 5 Then
For n = 5 To .Worksheets.Count
Worksheets(n).Delete
Next n
End If
End With
I receive a confirmation message box with this message:
"Data may exist in the sheet(s) selected for deletion. To permanently delete the data, press Delete" [DELETE] [CANCEL]
I wish to delete all sheets without receiving any message.
Is it possible?
Many thanks in advance for your kind support.
Regards,
Giovanni
I have the AutoOpen code that starts things off, and then, in turn, loads the UserForm with the fields that need to be populated.
I can't figure out how to route the user back to the UserForm, to enter the 'missed' data.
I have just tried running the following code
Code:
Dim ws As Worksheet For Each ws In ThisWorkbook.Sheets With ws If .FilterMode Then .ShowAllData End With Next ws
in the hope that it might 'unfilter' my table but it literally doesn't do a thing!
My table is called Activity_Table
Can you provide me with something that will 'unfilter' my table if it is filtered on any or all 6 columns?
Help appreciated,
Dominic
My excel file will contain more than one tab.
I have to free the first two lines in all the tabs except the first one.
I tried the following code.
Code:
xlsobj.Worksheets(1).Rows("1:2").Select ActiveWindow.FreezePanes = True
But in this I have to change the Active Worksheets in VBA, Which I want to avoid.
Is there any method to achieve this without selecting the cells.
Something like
Code:
xlsobj.Worksheets(1).Rows("1:2").FreezePanes = True
Until now I have been able to find all my answers through searches. As a VBA novice, it has been very helpful. I am stumped on this one, however. I am trying to autofill from the selected cell in Column C down. I would like it to stop at the last cell with data in Column B. This is the code I have so far:
Range("C2").Select
Selection.AutoFill Destination:=Range(Selection, Selection.End(xlDown))
This does the autofill, but doesn't stop at the last cell with data in Column B.
In the past I have use this code to acheive similar results:
Dim endRow As Long
endRow = Cells(Rows.Count, "B").End(xlUp).Row
Range("C2").AutoFill Destination:=Range("C2:C" & endRow)
The problem with this code is that I will not always be starting in "C2". I need code that uses whatever the selected cell is.
All help is appreciated. Thanks!
So far I can get everything to work besides the Submit part. The code runs without errors, but doesn't actually "hit" the submit button on the webpage.
For posting, I removed my actual user name and password and and used the generic " User Name " and " Password " highlighted in blue.
I highlighted another section in green that I took from a previous post hoping it would solve my problem. The link is: http://www.mrexcel.com/forum/showthr...xplorer+submit
Here is the code I am using:
Sub GoToWebSiteAndPlayAroundNew()
Dim appIE As Object ' InternetExplorer.Application
Dim URL As String
Set appIE = CreateObject("InternetExplorer.Application")
URL = " https://efolio.morgankeegan.com/escripts/defaultLogon.asp?errCode=2 "
With appIE
.navigate URL
.Visible = True
Do While .busy: DoEvents: Loop
Do While .ReadyState 4: DoEvents: Loop
.document.getelementbyid("fUserName").Value = " UserName "
.document.getelementbyid("fPassword").Value = " Password "
End With
On Error Resume Next
x = 0
For Each mitem In IE.document.all
mitem.Value = "x"
x = x + 1
Next
x = 0
For Each mitem In IE.document.all
If x = "Submit" Then
mitem.Click
Exit For
End If
Next
End Sub
Sub OpenPDF() 'Dim pdf As String On Error Resume Next 'pdf file to open pdf = "K:\PDF\mypdf.pdf" 'open the pdf file ActiveWorkbook.FollowHyperlink pdf End Sub
So then I tried to create an instance of acrobat by setting a reference to the acrobat object but I can't get this to work either!
The code I'm using is Code:
Sub OpenPDF() Dim pdf As AcroPDDoc Dim strPDF As String Set pdf = CreateObject("AcroExch.PDDoc") 'pdf file to open strPDF = "K:\PDF\mypdf.pdf" 'open the pdf file pdf.Open strPDF End Sub
Any ideas what could be wrong with either approach?
Thank-you
This is a very basic question, but i have been struggling for hours, so I must ask.
I I trying to simply fill a combobox on a userform from a named range on a sheet, I want to populate the combobox as soon as the userform starts. (I launch the userform from a button on the sheet) Where must I place the code? and will this code work?
Code:
Sub Button1_Click() Set UserForm1.combobox1.List = Sheets("Sheet1").Range("MyRange") UserForm1.Show End Sub
I am very new to vba, so please excuse my ignorance,
any help would be greatly appreciated
regards
jim
to display the data formatted. Right now I get all the ugly html codes, like
<b> Hello World</>.
Thanks - John