How to loop through worksheets and books in Excel

preview_player
Показать описание
Welcome to this video where I show how to loop through different worksheets and books in Excel. in order to better understand the code I can recommend going to Excel-easy, which is a site that helps freely with excel, check it out !

As always you can find the code used in the video here:

Sub Loopmacro()

Dim wbook As Workbook, wsheet As Worksheet, text As String

For Each wbook In Workbooks

text = text & "Workbook: " & wbook.Name & vbNewLine & "Worksheets: " & vbNewLine

For Each wsheet In wbook.Worksheets

text = text & wsheet.Name & vbNewLine

Next wsheet

text = text & vbNewLine

Next wbook

MsgBox text

End Sub
Рекомендации по теме