ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Move through the sheets of a workbook (https://www.excelbanter.com/excel-programming/396867-move-through-sheets-workbook.html)

Steve[_91_]

Move through the sheets of a workbook
 
What is the code to move through the sheets of a workbook one by one and
after processing the last sheet, stop?

Thanks!

Steve



Rick Rothstein \(MVP - VB\)

Move through the sheets of a workbook
 
What is the code to move through the sheets of a workbook one
by one and after processing the last sheet, stop?


Here is one way...

Sub TestCode3()
Dim WS As Worksheet
For Each WS In Worksheets
' Your code goes here in
' place of the following
WS.Range("A1") = WS.Name
Next
End Sub


Rick

Steve[_91_]

Move through the sheets of a workbook
 
Thanks, Rick!

Steve


"Rick Rothstein (MVP - VB)" wrote in
message ...
What is the code to move through the sheets of a workbook one
by one and after processing the last sheet, stop?


Here is one way...

Sub TestCode3()
Dim WS As Worksheet
For Each WS In Worksheets
' Your code goes here in
' place of the following
WS.Range("A1") = WS.Name
Next
End Sub


Rick





All times are GMT +1. The time now is 10:58 PM.

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