View Full Version : if acitve sheet, last sheet is


smiler44
11-21-2010, 02:08 AM
I want to know if I am active on the last worksheet. How? I do not know what the last worksheet name will be.

code needs to be something along the lines of
if this is the last worksheet then


I'd also like the code for
the last sheet name is.... but I do not want to selcet the last sheet to obtain the name



This was given to me, Worksheets(Worksheets.Count).Select
It selects the last sheet.

This tells me what the active sheet name is
MsgBox "current worksheet is " & ActiveSheet.Name


smiler44

Brianwarnock
11-21-2010, 04:07 AM
n = Worksheets.Count

lastname = Worksheets(n).Name

I'm sure that you can work with that to achieve what you want.

Brian

smiler44
11-21-2010, 04:46 AM
Brian,
thankyou. Thats got me on my way. I had tried using the brackets but had not got them right. Thanks again

Smiler44

Brianwarnock
11-21-2010, 05:00 AM
HTH and for anybody less experienced than Smiler who might come along I tested this since posting and as expected its fine

If ActiveSheet.Name = Worksheets(Worksheets.Count).Name Then

Brian