Support Amarindaz on Patreon: https://goo.gl/it9Gpk -~-
Title: How to loop through each sheet in Excel workbook using Excel VBA
Visit My Blog: http://www.amarindaz.com
Are you beginner to Excel VBA ? Check out my ebook: http://www.amarindaz.com/go/excel-vba/
Recommended Excel VBA books
===================================================
http://www.amarindaz.com/go/excel-vba...
http://www.amarindaz.com/go/excel-201...
http://www.amarindaz.com/go/excel-201...
====================================================
Facebook page: / amarindaz
In this video, you'll learn how to loop through each sheet in excel workbook using Excel VBA. Launch new Excel workbook go to developer tab - Visual basic- Insert a Module. Create a new sub routine and name it as loop_sheets and enter the below code
==========================================
Sub loop_sheets()
Set shts = ThisWorkbook.Sheets
Dim count As Integer
count = ThisWorkbook.Sheets.count
For i = 1 To count
Debug.Print ThisWorkbook.Sheets(i).Name
Next i
For Each sht In shts
If sht.Range("A1") = "TXT" Then
Debug.Print sht.Name
End If
Next
End Sub
=======================================
Using set command we are creating an object variable which defines the sheets in the workbook. I've explained two different methods to loop through the sheets.First one is using the for each loop and the second one using For.. Next loop. Using debug.print we are printing the name of sheets in that workbook. We also learned how to identify the sheet name as well as sheet index. I've also explained one simple practical example of looping through all sheets in a workbook.
💼 To Hire Me 👉 https://fwd.cx/WLGgpTiZW5HK
Checkout my app 👉 https://www.myfreshtools.com