I am running a macro on excel, and for some reason, the "Hours" tab doesn't seem to run if I press my macro once. But if I click my macro twice, it populates. My code is the following
Sub Refresh()
'
' Refresh Macro
'
'
Sheets("P DB").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("Cn DB").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
*Sheets("Years DB - CY").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False*
Sheets("E DB").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("Template").Select
Calculate
End Sub
This code:
Sheets("Years DB - CY").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
is what is running twice. FYI, Years DB - CY has a password and is connected to a server. So it should be able to refresh and ask for a password for the server each time.
Any help would be great! Thank you so much