Forum Discussion
Con13201328
Jun 23, 2022Copper Contributor
VBA for doing same action in a workbook
Hi all, i am not familiar with VBA but i would like to refresh for every tab in a single workbook. My workbook have difference numbers of sheet from time to time, so i can't use the record functi...
mtarler
Jun 26, 2022Silver Contributor
NikolinoDE , hi Niko, I also not sure what they need but was wondering if your macro should also span all worksheets. something like this?
Sub Query_aktual ()
Dim sh as Worksheets
ActiveWorkbook.RefreshAll
For s = 1 to ActiveWorkbook.sheets.count
For Each qt In ActiveWorkbook.sheets(s).QueryTables
qt.Refresh (BackgroundQuery)
Next
Next
End Sub
Con13201328
Jun 27, 2022Copper Contributor
Hi! mtarler
I have googled something similar but it is not running 😞
Dim i As Integer
Dim j As Integer
For i = 1 To Workbooks.Count
For j = 1 To Workbooks(i).Worksheets.Count
Workbooks(i).Worksheets(j).Application.Run"ImportWorksheet"
Next j
Next i
End Sub