Pramodpandit123
New Member
- Joined
- Apr 18, 2020
- Messages
- 30
- Office Version
- 2016
- Platform
- Windows
Whenever I run the following code i get "1004 Unable to set the visible property of the worksheet class" error while making the sheets visible. But it seems to perfectly work while hiding the sheets. How can i make the sheets stored in the array visible ?
P.S -> My worbook/worksheet is also not password protected.
P.S -> My worbook/worksheet is also not password protected.
VBA Code:
Sub sheets()
Dim i As Long, c As Long
Dim SheetArray() As String
With ActiveSheet.ListBoxSh
For i = 0 To .ListCount - 1
If .Selected(i) = False Then
ReDim Preserve SheetArray(c)
SheetArray(c) = .List(i)
c = c + 1
End If
Next i
Sheets(SheetArray()).Visible = xlSheetHidden
'SOME CODE HERE
Sheets(SheetArray()).Visible = xlSheetVisible
End With
End Sub