VBA List all Open Workbooks in Excel. It helps to know all open workbooks name. It is easy to handle and shift between workbooks. We have an option to open multiple workbooks in MS Office Excel. Let us see in the following tutorial how to list open Workbooks in Excel VBA.
Syntax to List Workbooks in Excel VBA
Here is the following syntax to List all Open Workbooks in Excel VBA.
For Each Workbook in Application.Workbooks Statements... Next
Where Workbook: It represents Workbook object which is part of workbooks collection.
VBA Code to List all Workbooks in Excel VBA
Let us see the following example macro to List all Open Workbooks in Excel VBA
'VBA List Open Workbooks in Excel Sub VBA_List_All_Open_Workbooks() 'Variable declaration Dim xWorkbook As Workbook Dim sWorkbookName As String Dim iCount As Integer 'Intialise value to a variable iCount = 2 Sheets("WB_Names").Range("A1") = "Names of Available Workbooks" 'Loop through all workbooks For Each xWorkbook In Application.Workbooks Sheets("WB_Names").Range("A" & iCount) = xWorkbook.Name & vbCrLf 'Increase value iCount = iCount + 1 Next End Sub
Instructions to Run VBA Macro Code or Procedure:
You can refer the following link for the step by step instructions.
Instructions to run VBA Macro Code
Other Useful Resources:
Click on the following links of the useful resources. These helps to learn and gain more knowledge.
VBA Tutorial VBA Functions List VBA Arrays in Excel Blog
VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers