danbrawl93
New Member
- Joined
- Dec 15, 2016
- Messages
- 17
Hey guys,
I am trying to run the following (simplified) code:
The For variable (sh in this case) is being used more than once, so the code doesn't work, but I need to scan through the worksheets in the nested loop. Please can you suggest ways to work around the issue!
Thanks so much in advance,
Dan
I am trying to run the following (simplified) code:
Code:
For Each sh In Worksheets
' I want to find if a particular sheet name exists
If sh.Name = "Desired Name" Then
' Now as a result I want to perform changes on specific sheets
For Each sh In Worksheets
If sh.name = "Example Name 1" Then
' Perform changes
ElseIf sh.Name = "Example Name 2" Then
' Perform changes
End If
Next sh
End If
Next sh
The For variable (sh in this case) is being used more than once, so the code doesn't work, but I need to scan through the worksheets in the nested loop. Please can you suggest ways to work around the issue!
Thanks so much in advance,
Dan