I have a workbook with about 60 sheets. Trying to write a code that will remove all sheets except for the one that the user is currently on. I need to do it using a variable (CurrentSheet) because the macro will run from any one of the sheets. Any ideas appreciated!
Code:
Dim WS As Worksheet
Dim CurrentSheet As String
CurrentSheet = ActiveSheet.Name
For Each WS In Worksheets
WS.Visible = True
If WS <> CurrentSheet Then
WS.Delete
Else
End If
Next
Code:
Dim WS As Worksheet
Dim CurrentSheet As String
CurrentSheet = ActiveSheet.Name
For Each WS In Worksheets
WS.Visible = True
If WS <> CurrentSheet Then
WS.Delete
Else
End If
Next