Hi All,
I need to run a specific code on multiple worksheets (Only for selected worksheets) within same workbook.
Any suggestions?
Appreciate your support.
Thanks!
VBA Code on multipe sheets
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA Code on multipe sheets
For example:
You should not assume that w is the active sheet in the part between For Each w and Next w unless you use w/Select, but that is usually less efficient.
Code: Select all
Sub Example()
Dim w As Worksheet
For Each w In Worksheets(Array("ThisSheet", "ThatSheet", "OtherSheet"))
' Do something with w
Next w
End Sub
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 27
- Joined: 24 Jun 2020, 01:39
Re: VBA Code on multipe sheets
Thanks, it works!