'VBA Call Multiple Macros from Command Button and change one macro in loop - EXPETED FUNCTION OR VARIABLE
Sub Save_All_Files()
Call Account_Name_And_Year_1
Call Data_2021_1
Call Account_Name_And_Year_1
Call Data_2022_1
With Account_Name_And_Year_1
rootAccount = ws.Cells(103, 10).Value
year = ws.Cells(102, 11).Value
For Each pt In ws.PivotTables
With pt
With .PivotFields("Root Account")
.CurrentPage = rootAccount
End With
With .PivotFields("Year")
.CurrentPage = year
End With
End With
Next pt
End With
Call Data_2021_1
Call Data_2022_1
End Sub
I have a list of 3 Master with Account name in Column J row 101 to row 200+ and year in Column K row 101(2021) and row 102(2022). Macro Account_Name_And_Year changes pivot fields (Account name & year) in all Pivot tables in all 3 workbooks), Macro Data_2021_1 copies the data from all Pivot Tables from all 3 workbooks and paste it in template file(sheet1), then again Macro Account_Name_and_Year_1 changes pivot fields(this time only year to 2022 from "K102") and then Macro Data_2022_1 copies the data from all Pivot Tables from all 3 workbooks and paste it in template file(sheet2).
I was trying to do it for all accounts in one single click. Is it possible via calling macro and then editing it. Or is there any simpler way to save all 100+ files in single with with above conditions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
