Hey team,
Hopefully this is an easy one to solve, but sitting here scratching my head on this one. When I run the below code, I get the following error and can't seem to figure out why...
Error
Run-time error '1004':
Method 'Visible' of object '_Worksheet' failed
Background
Macro that I am currently running loops through a set of .xlsx files in a folder and manipulates them one by one, assigning the current workbook as wbOpened and in this section of code loops through the workbooks tab, and hides all tabs that aren't named 'Subscribers' or 'Subscriber Check'.
<code>
Now the line I am getting an error on is the line below Case Else 'wshSheet.visible = xlSheetHidden' and can't seem to understand why as I swear this code worked a moment ago.
Any help would definitely be appreciated!!
Kind regards, s0up2up
Hopefully this is an easy one to solve, but sitting here scratching my head on this one. When I run the below code, I get the following error and can't seem to figure out why...
Error
Run-time error '1004':
Method 'Visible' of object '_Worksheet' failed
Background
Macro that I am currently running loops through a set of .xlsx files in a folder and manipulates them one by one, assigning the current workbook as wbOpened and in this section of code loops through the workbooks tab, and hides all tabs that aren't named 'Subscribers' or 'Subscriber Check'.
<code>
Code:
For Each wshSheet In wbOpened.Worksheets Select Case wshSheet.Name
'Hide sheets unless name is either 'Subscribers' or 'Subscriber Check'
Case "Subscribers"
wshSheet.Visible = xlSheetVisible 'ensure sheet is visible
Set wshSubscribersSheet = wshSheet 'populate wshSubscribersSheet object
Case "Subscriber Check"
wshSheet.Visible = xlSheetVisible 'ensure sheet is visible
Set wshSubscriberCheck = wshSheet 'populate wshSubscriberCheck object
Case Else
wshSheet.Visible = xlSheetHidden 'hide sheet
End Select
Next wshSheet
</code>
Now the line I am getting an error on is the line below Case Else 'wshSheet.visible = xlSheetHidden' and can't seem to understand why as I swear this code worked a moment ago.
Any help would definitely be appreciated!!
Kind regards, s0up2up
Last edited: