whats the code for "if activesheet ="

smiler44

Registered User.
Local time
Today, 21:05
Joined
Jul 15, 2008
Messages
690
I can not believe I am stuck again on something that seems to simple.

Could you help me with the correct code for

If activesheet = "sheet25" Then
MsgBox ("completed")
End If

Thank you in advance
smiler44
 
If you are doing this IN Excel then you can use

If ActiveSheet.Name = "sheet25" Then
...etc.

If in Access then you should not use Activesheet unless you can refer to the main application object.
 
Bob,
thank you, yes doing it from a module in Excel. Checking the properties to sheet25 leads my to think I have phrased my question wrong as your code is right. The (Name) is sheet25 but the Name is mobilehub. I would not have worked out what I was doing wrong without your help so thank you.

sheet25 / mobilehub is the last sheet in my workbook. Pondering why my reluctance to hardcode the last sheet name when I was happy to use sheet25 led me to want something more flexible. I have through trial and error and by luck arrived at code

If Worksheet = lastworksheet Then
MsgBox ("completed")
End If

This seems to work and is more flexible and ultimately what I want to know, when I'm at the last work sheet.

smiler44
 
An other way would probably be

If Activesheet.Name = Worksheets(Worksheets.Count).Name

(air code)
 
A simple bit of code that has taken me some time to find but may be of use. Note the use of brackets, very important.
Code:
If (ActiveSheet.Name) = "Sheet1" Then

smiler44
 

Users who are viewing this thread

Back
Top Bottom