【VBA】Repeat for the number of sheets.

You can repeat for the number of sheets.

PR

VBA Code

As an example, There is an Excel file with the following three sheets:

sample01
sample02
sample03

 three sheets
three sheets
Option Explicit

Sub sample()
    
    Dim ws As Worksheet
   
    For Each ws In ThisWorkbook.Worksheets
        'output to "immediate window"
        Debug.Print ws.Name
    Next
    
End Sub
PR

Result

You repeated for the number of sheets!

Result
Result
PR

FYI

For more information about following, see the following official online manual:

●Worksheets Object


●Worksheet Object

タイトルとURLをコピーしました