View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default run macro in multiple worksheets

Yes but what do you want to do ?
Maybe you not need to unhide the sheet first

This will work

Change the .PrintOut
line to your code

Sub Print_Hidden_And_Visible_Worksheets()
'Dave Peterson
Dim CurVis As Long
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
With sh
CurVis = .Visible
.Visible = xlSheetVisible
.PrintOut
.Visible = CurVis
End With
Next sh
End Sub

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SteveDB1" wrote in message ...
Ok, so by the sounds of it, I'd need to unhide all the worksheets first, and
then run the macro.
Is there a way to unhide a worksheet, run the macro, and then rehide it--
one hidden worksheet at a time, "automatically?"
Again.... thank you for your helps.


"Ron de Bruin" wrote:

You can't select hidden sheets that's why it blow

See how I test if it is visible in this macro
http://www.rondebruin.nl/copy6.htm

You can also use xlSheetVisible instead of -1

Btw: In most cases you not have to select the sheets

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SteveDB1" wrote in message ...
Hidden worksheets?
Actually, yes, there are. On most all of our workbook files that I'll be
using this on too.
And after I got an answer to this I was going to post on modifying hidden
worksheets with the macro.
How do I resolve that?
I.e., how can I have the macro process ALL ofthe worksheets, including the
hidden ones?
Don, the other macro works great without the "ALL worksheets" component.
It was after I'd added the ALL portion that I got the error.




"Ron de Bruin" wrote:

Do you have a hidden worksheet in your workbook ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SteveDB1" wrote in message ...
Hi all.
Back on April 7, 2006 an individual calling themselves
Yardbird(http://www.microsoft.com/communities...5-233243fafda4)
posted on their desire to run a macro in a workbook to cover all the
worksheets in a workbook.
Gary Brown, Tom Ogilvy, and Bob Phillips responded with their resolution.
I'm now trying the code they used, and get a 1004 error. I did replace the
workbook.worksheets with activeworkbook.worksheets.

Dim sh as Worksheet
for each sh in ActiveWorkbook.Worksheets
sh.Select
'code for my macro here....
Next Sh

It appears to get hung up on the 'sh.select', stating that "sh is nothing."

how do I resolve this to get it working?
(my macro code works great without this, and would like to get it to work
for all worksheets in a single stroke. )
Thank you.
Best.