ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros in PERSONAL.XLS (https://www.excelbanter.com/excel-programming/440032-macros-personal-xls.html)

mdmaremont

Macros in PERSONAL.XLS
 
Excel 2003; Windows XP OS. I have a series of macros in my PERSONAL.XLS
workbook that create a number of different pivot tables. I can't set up to
run automatically, as I must create the datatables daily and they are a
different size each day. The macros must be executed in the order they were
created or they 'bomb'. When I look at the VBA code, each different macro
contains a numbered pivottable reference, reflecting its creation order (e.g.
PivotTable3). Is there a way to make the references valid regardless of the
order in which they are executed?

Peter T

Macros in PERSONAL.XLS
 
When you create the PivotTable with code you have the opportunity to give it
your own name, record a macro and look at the arguments, eg
TableName:="<pivotTable-name"

When you want to refer that PivotTable later

Dim pt As PivotTable
Set pt = ActiveWorkbook.Worksheets("Sheet1").PivotTables("m yPvtTble")

Regards,
Peter T


"mdmaremont" wrote in message
...
Excel 2003; Windows XP OS. I have a series of macros in my PERSONAL.XLS
workbook that create a number of different pivot tables. I can't set up
to
run automatically, as I must create the datatables daily and they are a
different size each day. The macros must be executed in the order they
were
created or they 'bomb'. When I look at the VBA code, each different macro
contains a numbered pivottable reference, reflecting its creation order
(e.g.
PivotTable3). Is there a way to make the references valid regardless of
the
order in which they are executed?





All times are GMT +1. The time now is 08:10 AM.

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