Call Macros

praveenlal

New Member
Joined
Oct 27, 2021
Messages
34
Office Version
  1. 2016
Platform
  1. Windows
Is it possible to call Macro and then edit its variables ?

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

With wb
With ws

rootAccount = ws.Cells(101, 10).Value
year = ws.Cells(101, 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
End With
Next pt
End With

Call Data_2021_1
Call Data_2022_1

End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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.
Not sure exactly what you are trying to do, but maybe this will help: Calling Sub and Function procedures (VBA)
This shows you how you can pass values into your Procedures.
 
Upvote 0
OK, that is not what I thought you were looking for.
I really do not use Pivot Tables at all, and certainly have not tried automating them via VBA.
So I don't think I will be able to provide much guidance here.
Perhaps someone else who is more experienced with Pivot Tables (and using VBA with Pivot Tables) will weigh in.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,116
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top