Why does this code not work?
Dim wks as object
dim myCodeName as string
dim mySheet as object
set mysheet = nothing
mycodename = "Sheet1"
for each wks in activeworkbook.sheets
if lcase(wks.codename) = lcase(mycodename) then
set mysheet = wks
'stop looking
exit for
end if
next wks
if mysheet is nothing then
msgbox "Not found!"
else
mysheet.select
end if
rk0909 wrote:
All,
I am trying to use the code name of sheets instead of the tab name, but it
wouldn't work for me. Any help will be appreciated.
Thanks much,
RK
Sub test()
Dim n As Integer
n = 1
wks = "sheet" & n
wks.Select
End Sub
--
Dave Peterson
|