ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to Select All Sheets and Make Change to Footer (https://www.excelbanter.com/excel-discussion-misc-queries/203032-macro-select-all-sheets-make-change-footer.html)

Karin

Macro to Select All Sheets and Make Change to Footer
 
Hi, I need help with this code, please. I want to select all the sheets in
one workbook and change the right footer to nothing, then select the A1 on
the first worksheet. What am I missing? Thank you!

Worksheets.Select
PageSetup.RightFooter = ""
Sheets(1).Select
Range("A1").Select


Jim Thomlinson

Macro to Select All Sheets and Make Change to Footer
 
There is a problem wiht doin a pagesetup to all sheets. VBA can only do it
one sheet at a time... Your code is equivalent to

Worksheets.Select
Activesheet.PageSetup.RightFooter = "" '**Activesheet only
Sheets(1).Select
Range("A1").Select

Try this... It does not select anything so your user will be left exactly
where they were when the started the macro.

Sub test()
Dim wks As Worksheet

For Each wks In Worksheets
wks.PageSetup.RightFooter = ""
Next wks
End Sub

--
HTH...

Jim Thomlinson


"Karin" wrote:

Hi, I need help with this code, please. I want to select all the sheets in
one workbook and change the right footer to nothing, then select the A1 on
the first worksheet. What am I missing? Thank you!

Worksheets.Select
PageSetup.RightFooter = ""
Sheets(1).Select
Range("A1").Select


Karin

Macro to Select All Sheets and Make Change to Footer
 
It seems to go to next sheet and on from there without changing the sheet you
are on or the sheets before it.

"Jim Thomlinson" wrote:

There is a problem wiht doin a pagesetup to all sheets. VBA can only do it
one sheet at a time... Your code is equivalent to

Worksheets.Select
Activesheet.PageSetup.RightFooter = "" '**Activesheet only
Sheets(1).Select
Range("A1").Select

Try this... It does not select anything so your user will be left exactly
where they were when the started the macro.

Sub test()
Dim wks As Worksheet

For Each wks In Worksheets
wks.PageSetup.RightFooter = ""
Next wks
End Sub

--
HTH...

Jim Thomlinson


"Karin" wrote:

Hi, I need help with this code, please. I want to select all the sheets in
one workbook and change the right footer to nothing, then select the A1 on
the first worksheet. What am I missing? Thank you!

Worksheets.Select
PageSetup.RightFooter = ""
Sheets(1).Select
Range("A1").Select



All times are GMT +1. The time now is 12:13 PM.

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