PDA

View Full Version : Solved: Find a sheet name



ron
06-05-2009, 07:39 AM
Hey,

I need assistance with writing the code to place the sheet name in a variable that is directly to the right of a sheet named Index.

Thanks

ron

Bob Phillips
06-05-2009, 07:42 AM
You can't have a sheet named Index, Excel rejects it.

Bob Phillips
06-05-2009, 07:45 AM
Sorry, that was juts my Excel playing up.

Try this



myVar = worksheets(worksheets("Index").index+1).name

Bob Phillips
06-05-2009, 07:47 AM
Bit of error checking might help



If Worksheets("Index").Index < Worksheets.Count Then

myVar = Worksheets(Worksheets("Index").Index + 1).Name
Else

MsgBox "Oops!"
End If

ron
06-05-2009, 07:56 AM
xld,

It works perfect, thanks

ron