willow1985
Well-known Member
- Joined
- Jul 24, 2019
- Messages
- 929
- Office Version
- 365
- Platform
- Windows
I am getting the above runtime error on the line below marked with a ****
If anyone could help me with what I am missing that would be wonderful.
Thank you
If anyone could help me with what I am missing that would be wonderful.
Thank you
VBA Code:
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub OTD()
'
' OTD Macro
Dim OTDD As String
Dim OTDN As String
OTDD = Workbooks("Dashboard ").Sheets("List").Range("B46").Value
OTDN = Workbooks("Dashboard ").Sheets("List").Range("B47").Value
Sheets("OTD").Select
Application.EnableEvents = True
For Each lo In ActiveSheet.ListObjects
lo.AutoFilter.ShowAllData
Next lo
If (ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode) Or ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
Cells.EntireColumn.Hidden = False
Workbooks.Open OTDD
Windows(OTDN).Activate
Sheets("1 Data").Range("A1:S1000000").ListObject.QueryTable.Refresh BackgroundQuery:=False '****
Sleep 2
Sheets("2 Data").Range("A1:AB1000000").ListObject.QueryTable.Refresh BackgroundQuery:=False
Sleep 2
Sheets("3 Data").Range("A1:AA1000000").ListObject.QueryTable.Refresh BackgroundQuery:=False
Sleep 2
Sheets("4 Data").Range("A1:AB1000000").ListObject.QueryTable.Refresh BackgroundQuery:=False
Sleep 2
Sheets("Stats").Select
Range("A3:G14").Select
Selection.Copy
Windows("Dashboard.xlsm").Activate
Sheets("OTD").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows(OTDN).Activate
Sheets("2 Stats").Select
Range("A3:G14").Select
Selection.Copy
Windows("Dashboard.xlsm").Activate
Sheets("OTD").Select
Range("I2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows(OTDN).Activate
Sheets("3 Stats").Select
Range("A3:G14").Select
Selection.Copy
Windows("Dashboard.xlsm").Activate
Sheets("OTD").Select
Range("Q2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows(OTDN).Activate
Sheets("4 Stats").Select
Range("A3:G14").Select
Selection.Copy
Windows("Dashboard.xlsm").Activate
Sheets("OTD").Select
Range("Y2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Workbooks(OTDN).Close False
Windows("Dashboard xlsm").Activate
Range("A1").Select
End Sub