View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
klysell klysell is offline
external usenet poster
 
Posts: 146
Default Moving through worksheets and enacting formatting macro

Hey Susan,

This works well, but I was wondering if I could enact one macro button on
the "Parameters, Macros" sheet that moves through all my worksheets that
contain pivot tables and then subsequently refreshes and formats them using
my "Formatting" procedure.

Thanks,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


"Susan" wrote:

hi kent
try splitting it up - put the actual formatting macro in a regular
module, rather than behind a sheet, & have the command button call the
2nd macro.

sub commandbutton1_click()
Call Format_Stuff
end sub

public sub Format_Stuff()
do your stuff
end sub

make sure it's a public sub.
hope that helps!
susan







On Aug 3, 9:20 am, klysell wrote:
Hi,

I have a macro assigned to the CommandButton1 on each worksheet starting on
the sixth worksheet and going until the last tab of my workbook. In each
instance, the macro does the same procedure, but only acting on the worksheet
to which it is attached. How do I move through these worksheets one-at-a-time
and enact the macro button?

The procedure that is assigned to this button is called "formatting" and
deals with formatting my pivot tables. I've tried other more efficient
methods, but they seem to only act on my summary sheet and not move through
my workbook.

Here is the code that I've come up with thus far:

Dim pt As PivotTables
Dim sh As Worksheet

For Each ws In sh.PivotTables
With pt
Call Formatting(pt)
End With
Next ws

What am I doing wrong?

Thanks in advance,
Kent.
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557