![]() |
Selecting the current month using a macro on a pivot table
I have a macro set to run every day. In the pivot table it chooses Nov. How
can I get this to choose the current month so that I don't have to change it every month. Also can make the change to current month on the 5th business day to the current month? ActiveSheet.PivotTables("PivotTable2").AddFields ColumnFields:= _ "MKT_REGION_NAME " With ActiveSheet.PivotTables("PivotTable2").PivotFields ("NOV") .Orientation = xlDataField .Caption = "Sum of NOV" .Function = xlSum |
Selecting the current month using a macro on a pivot table
just replace
"NOV" with UCase(WorksheetFunction.Text(Now, "mmm")) -- Gary's Student "Newbee" wrote: I have a macro set to run every day. In the pivot table it chooses Nov. How can I get this to choose the current month so that I don't have to change it every month. Also can make the change to current month on the 5th business day to the current month? ActiveSheet.PivotTables("PivotTable2").AddFields ColumnFields:= _ "MKT_REGION_NAME " With ActiveSheet.PivotTables("PivotTable2").PivotFields ("NOV") .Orientation = xlDataField .Caption = "Sum of NOV" .Function = xlSum |
Selecting the current month using a macro on a pivot table
Thank you!
"Gary''s Student" wrote: just replace "NOV" with UCase(WorksheetFunction.Text(Now, "mmm")) -- Gary's Student "Newbee" wrote: I have a macro set to run every day. In the pivot table it chooses Nov. How can I get this to choose the current month so that I don't have to change it every month. Also can make the change to current month on the 5th business day to the current month? ActiveSheet.PivotTables("PivotTable2").AddFields ColumnFields:= _ "MKT_REGION_NAME " With ActiveSheet.PivotTables("PivotTable2").PivotFields ("NOV") .Orientation = xlDataField .Caption = "Sum of NOV" .Function = xlSum |
Selecting the current month using a macro on a pivot table
You are very Welcome !
-- Gary's Student "Newbee" wrote: Thank you! "Gary''s Student" wrote: just replace "NOV" with UCase(WorksheetFunction.Text(Now, "mmm")) -- Gary's Student "Newbee" wrote: I have a macro set to run every day. In the pivot table it chooses Nov. How can I get this to choose the current month so that I don't have to change it every month. Also can make the change to current month on the 5th business day to the current month? ActiveSheet.PivotTables("PivotTable2").AddFields ColumnFields:= _ "MKT_REGION_NAME " With ActiveSheet.PivotTables("PivotTable2").PivotFields ("NOV") .Orientation = xlDataField .Caption = "Sum of NOV" .Function = xlSum |
All times are GMT +1. The time now is 07:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com