0

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

Cyril
  • 6,448
  • 1
  • 18
  • 31
Scott P
  • 29
  • 8
  • Delete from `Select // .Selection` from each line and subsequent line (`sheets().listobject.`), plus the `select` before `calculate` ... that'll be the first big help. – Cyril Nov 12 '19 at 18:24
  • What is in the Hours tab? Is it a dependent formula? – Cyril Nov 12 '19 at 18:26
  • sorry my "hours" are on the template page. It is a dependent formula that relies on my "Years DB - CY" – Scott P Nov 12 '19 at 18:48

0 Answers0