ransomedbyfire
Board Regular
- Joined
- Mar 9, 2011
- Messages
- 121
When I run the following code, for some reason, Excel activates Sheet9 when I tell it to activate Sheet8. I have looked at the sheet properties, and everything seems fine - just not in execution. How can I fix this without having to use a workaround?
Here is a simplified snippet of my code:
When I run this code, the sheet that is labeled "Sheet8" in the Project window slips through the IF statement uncaught and cname is set to equal "Sheet9".
I have used this code successfully with sheets 1-7; so, it should work here too. But it doesn't.
Can someone please help me with this?
Here is a simplified snippet of my code:
Code:
Dim ws as Worksheet
For Each ws in Worksheets
if ws.codename<>"Sheet8" Then
ws.Activate
cname=ws.codename
End If
Next ws
When I run this code, the sheet that is labeled "Sheet8" in the Project window slips through the IF statement uncaught and cname is set to equal "Sheet9".
I have used this code successfully with sheets 1-7; so, it should work here too. But it doesn't.
Can someone please help me with this?