ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Make macro run on all worksheets except the first (https://www.excelbanter.com/excel-programming/392684-make-macro-run-all-worksheets-except-first.html)

Tiger

Make macro run on all worksheets except the first
 
Hi,

I am trying to write an auto run macro that runs on each worksheet in the
workbook except the first upon opening. I am using

Sub Auto_Open()
'
' Auto_Open Macro
' Macro recorded 29/05/2007 by Kirsty Liddicoat
'

Dim ws As Worksheet
For Each ws In Worksheets(Array(2, 3, 4, 5, 6))
'macro action
Next ws

End Sub

being what I am trying to achieve. This is working but the macro is only
running on the sheet it opens up on not all of the worksheets.

Any suggestions?


Otto Moehrbach

Make macro run on all worksheets except the first
 
Tiger
The macro you have, as written, will always work on the active sheet.
Nothing in your macro changes the active sheet. Add the following line
before "'macro action:
ws.select
HTH Otto
"tiger" wrote in message
...
Hi,

I am trying to write an auto run macro that runs on each worksheet in the
workbook except the first upon opening. I am using

Sub Auto_Open()
'
' Auto_Open Macro
' Macro recorded 29/05/2007 by Kirsty Liddicoat
'

Dim ws As Worksheet
For Each ws In Worksheets(Array(2, 3, 4, 5, 6))
'macro action
Next ws

End Sub

being what I am trying to achieve. This is working but the macro is only
running on the sheet it opens up on not all of the worksheets.

Any suggestions?





All times are GMT +1. The time now is 02:23 PM.

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