Home>Blogs>VBA>Loop Through in Worksheets, Sheets & Chart in VBA
Loop Through Worksheets

Loop Through in Worksheets, Sheets & Chart in VBA

In this article, we have explained the difference between Chart Sheet and Worksheet in Excel. We have also explained how to loop through the Charts, Sheets and Worksheets.

The difference between Chart Sheets and Worksheets

A Worksheets are Sheets, but not all Sheets are Worksheets.  There are 2 types of Sheets:

Worksheet: The sheet with the grid-lines and cells.


Chart Sheet: The sheet which contains a single chart.

Chart Sheet
Chart Sheet

Loop through Worksheets –

Sub LoopthroughinWorksheets()

Dim i As Integer
Dim wsh As Worksheet

For Each wsh In ThisWorkbook.Worksheets
MsgBox wsh.Name

End Sub

Loop through Sheets –

Sub LoopthroughinSheets()

Dim i As Integer

For i = 1 To ThisWorkbook.Sheets.Count
MsgBox ThisWorkbook.Sheets(i).Name

Next i

End Sub

Loop through Chart Sheets–

Sub LoopThroughinChartsheets()

Dim cht As Chart

For Each cht In ThisWorkbook.Charts

MsgBox cht.Name

End Sub


Click here to download practice file-

Watch the step by step video tutorial:

Meet PK, the founder of PK-AnExcelExpert.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your Excel skills to the next level!