Pivot Selection

M

mph999

I need VBA to format Data in a pivot, but not include the name of th
pivot.

I use many pivots and want to format the data as £000, or £n.
In each sheet with a pivot, I have 2 commandbuttons calling VBA t
format the Data. The command buttons are in each sheet with a pivot.
The code is:
ActiveSheet.PivotTables("PivotName22").PivotSelect "", xlDataOnly
True
Selection.NumberFormat = "#,###, ;[Red](#,###,);- "
End Sub

This code is specific to A pivot and I want to use the same comman
button + VBA combination for ANY pivot.

Problem = I can't re-write the above VBA so it can be used in AN
pivot.

Thanks in anticipation
 
I

Ivan Raiminius

Hi,

you can use index instead of pivot table name (means number), or you
can use string variable as name in your code.

If you want all command buttons to call the same procedure and need to
know which command button was clicked, use application events.

Regards,

Ivan
 
M

mph999

Thanks Ivan

1st para; I don't understand this solution. I'm not a VBA expert,
maybe that's why.

2nd para - your right, the command buttons are always commandbutton1 &
commandbutton2. 1 calls VAB for 000's format, 2 calls units/n format.
But each pivot has unique name and the formatting VBA I have [in
example] is specific to one unique pivot. I want to use the
commandbutton/VBA combination to format ANY pivot.

Hope this clarifies my original question; apologies for for causing any
confusion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top