ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Apply Macro on Multiple Worksheets in a Workbook (https://www.excelbanter.com/excel-programming/310962-apply-macro-multiple-worksheets-workbook.html)

Agnes

Apply Macro on Multiple Worksheets in a Workbook
 

When I output financial reports from the Financial Report Writer FRx t
Excel, report always come out in a messy format that I have to adjus
page format so each worksheet will be printed on 1 page in a readabl
format (each output file/workbook usually has 30 worksheets).

I have created a macro to do the formatting: adjust all margins t
0.25, make page portrait and scale to fit page to 1 wide by 1 tall.

But the macro can only be applied to the worksheet I selected. I'v
tried highlighting all worksheets and even included the highlight al
sheet action in the script, but the macro only works on the page I'
in.

Is there anyway I can apply a macro to all worksheets? A challeng
here is that the worksheet name in each workbook is different an
worksheets in each workbook could be different each period (I don'
always generate the same worksheets).

I have been manuall highlighting all worksheets to adjust page forma
for 30 reports each month. I'd really appreciate if you could help m
come up with a more effiencent way to do it. Thanks in advance!

Agne

--
Agne
-----------------------------------------------------------------------
Agnes's Profile: http://www.excelforum.com/member.php...fo&userid=1463
View this thread: http://www.excelforum.com/showthread.php?threadid=26261


Norman Jones

Apply Macro on Multiple Worksheets in a Workbook
 
Hi Agnes,

One approach:

Sub Tester()
Dim sh As Worksheet

For Each sh In ActiveWorkbook.Worksheets
'Your format code
Next sh

End Sub

---
Regards,
Norman



"Agnes" wrote in message
...

When I output financial reports from the Financial Report Writer FRx to
Excel, report always come out in a messy format that I have to adjust
page format so each worksheet will be printed on 1 page in a readable
format (each output file/workbook usually has 30 worksheets).

I have created a macro to do the formatting: adjust all margins to
0.25, make page portrait and scale to fit page to 1 wide by 1 tall.

But the macro can only be applied to the worksheet I selected. I've
tried highlighting all worksheets and even included the highlight all
sheet action in the script, but the macro only works on the page I'm
in.

Is there anyway I can apply a macro to all worksheets? A challenge
here is that the worksheet name in each workbook is different and
worksheets in each workbook could be different each period (I don't
always generate the same worksheets).

I have been manuall highlighting all worksheets to adjust page format
for 30 reports each month. I'd really appreciate if you could help me
come up with a more effiencent way to do it. Thanks in advance!

Agnes


--
Agnes
------------------------------------------------------------------------
Agnes's Profile:
http://www.excelforum.com/member.php...o&userid=14630
View this thread: http://www.excelforum.com/showthread...hreadid=262619





All times are GMT +1. The time now is 11:17 PM.

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