Karthik Thandapani
Member
Hi,
When I run the below code, it's throwing up an error.
Previously, I was using this code in an userform and it was working well. Presently, I've moved the code to Module1 and tying to call from the userform, am I doing something incorrectly?
Please recommend any workaround.
p.s: actual logic is to have an userform to show sheet names in listbox. As user selects sheets, this will get copied by array formula.
Thanks,
Karthik
When I run the below code, it's throwing up an error.
Code:
Dim Selected_Sheets As String
Dim Sheets_Array As Variant
Dim I As Integer
With Me
For I = 1 To .ListBox1.ListCount
If .ListBox1.Selected(I - 1) Then
Selected_Sheets = Selected_Sheets & "," & .ListBox1.List(I - 1)
End If
Next
Selected_Sheets = Mid(Selected_Sheets, 2)
Sheets_Array = Split(Selected_Sheets, ",")
Application.DisplayAlerts = False
ThisWorkbook.Worksheets(Sheets_Array).Copy
Application.DisplayAlerts = True
End With
Previously, I was using this code in an userform and it was working well. Presently, I've moved the code to Module1 and tying to call from the userform, am I doing something incorrectly?
Please recommend any workaround.
p.s: actual logic is to have an userform to show sheet names in listbox. As user selects sheets, this will get copied by array formula.
Thanks,
Karthik