ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Record Pivot Table Macro (https://www.excelbanter.com/excel-discussion-misc-queries/71004-record-pivot-table-macro.html)

Corey

Record Pivot Table Macro
 
I'm trying to incorporate a pivot table creation in a macro, but can't get
around the specific name of the sheet it's identifying. For instance, the
code states '1205 Aging' as the sheet name in the code. Obviously this would
be different each month so the macro wouldn't be 'universal'. Any ideas?

Thanks.

bpeltzer

Record Pivot Table Macro
 
If the macro will be run from the sheet containing the data, you can replace
the SourceData portion of the code to reference the ActiveSheet, rather than
using a fixed sheet name. For example, change
SourceData:="Sheet1!R1C1:R5C2" to
SourceData:=ActiveSheet.Name & "!R1C1:R5C2"
--Bruce


"Corey" wrote:

I'm trying to incorporate a pivot table creation in a macro, but can't get
around the specific name of the sheet it's identifying. For instance, the
code states '1205 Aging' as the sheet name in the code. Obviously this would
be different each month so the macro wouldn't be 'universal'. Any ideas?

Thanks.


Corey

Record Pivot Table Macro
 
Thanks! That worked fine.

"bpeltzer" wrote:

If the macro will be run from the sheet containing the data, you can replace
the SourceData portion of the code to reference the ActiveSheet, rather than
using a fixed sheet name. For example, change
SourceData:="Sheet1!R1C1:R5C2" to
SourceData:=ActiveSheet.Name & "!R1C1:R5C2"
--Bruce


"Corey" wrote:

I'm trying to incorporate a pivot table creation in a macro, but can't get
around the specific name of the sheet it's identifying. For instance, the
code states '1205 Aging' as the sheet name in the code. Obviously this would
be different each month so the macro wouldn't be 'universal'. Any ideas?

Thanks.



All times are GMT +1. The time now is 02:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com