Hi
Not sure exactly what you are trying to do, but try this .
You may be able to modify to work as you want.
For i = 1 To ActiveWorkbook.Worksheets.Count
If ActiveWorkbook.Worksheets(i).CodeName = "Sheet1" Then
Set ws = ActiveWorkbook.Worksheets(i)
ws.Activate
Exit For
End If
Next i
HTH
Ken
"Michael D. Ober" wrote in message
ink.net...
I have some VBA code that does the following:
Option Compare Text
for i = 1 to ActiveWorkBook.Worksheets(i)
if ActiveWorkBook.Worksheets(i).CodeName = "Sheet1" then
set ws = ActiveWorkBook.Worksheets(i)
exit for
end if
next i
The problem is that this code doesn't always return as expected. In the
debuger, it always works, when run from an Add-In menu item, it works
about
10% of the time.
Any ideas,
Thanks,
Mike.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.525 / Virus Database: 322 - Release Date: 09/10/2003