In a User form I would like to display two listboxs . In the listbox1 I would display the Opened Workbooks with the Exception of the Personal Workbook; and whenever I click one of the Workbooks in the Listbox1 I would like to display the Worksheets available in that workbook in the Listbox2. Doing some research I found the following code which represent how far I have been able to go about this:
Private Sub UserForm_Initialize()
UserForm1.Caption = "Workbooks and Sheets"
Dim wb As Workbook
Dim n As Long
For Each wb In Application.Workbooks
ListBox1.AddItem wb.Name
Next wb
For n = 1 To ActiveWorkbook.Sheets.Count
ListBox2.AddItem ActiveWorkbook.Sheets(n).Name
Next n
End Sub
Also I found this Post in Here but I should be doing something wrong because when I run the code both list box appear without any content whatsoever. Do you know How could I get this code to Work? Thank you