Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi.. Below is part of some code I'm running.. This part: InStr(1, .Name, "OT", vbTextCompare) Call PrintareaOT2 is running when the "Other Deductions" workheet is active.. so I am asumming it's picking up the OT in the Other Deductions name. Is there a way to have this code check the sheet's name. The reason for not identifying the exact names of the sheets is because there can be multiple sheets with the same name ...they just have numbers after them.... like Other Deductions (2).. and so on ... and OT (2) and so on... *********************** With ActiveSheet If InStr(1, .Name, "OT", vbTextCompare) Then Call PrintareaOT2 End If If InStr(1, .Name, "Other Deductions", vbTextCompare) Then Call PrintareaDeductions2 End If End With As Always.. thanks in advance!! Kimberly |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe you can just search for more of the name:
If InStr(1, .Name, "OT (", vbTextCompare) Then KimberlyC wrote: Hi.. Below is part of some code I'm running.. This part: InStr(1, .Name, "OT", vbTextCompare) Call PrintareaOT2 is running when the "Other Deductions" workheet is active.. so I am asumming it's picking up the OT in the Other Deductions name. Is there a way to have this code check the sheet's name. The reason for not identifying the exact names of the sheets is because there can be multiple sheets with the same name ...they just have numbers after them.... like Other Deductions (2).. and so on ... and OT (2) and so on... *********************** With ActiveSheet If InStr(1, .Name, "OT", vbTextCompare) Then Call PrintareaOT2 End If If InStr(1, .Name, "Other Deductions", vbTextCompare) Then Call PrintareaDeductions2 End If End With As Always.. thanks in advance!! Kimberly -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
An added thought:
If you also have a sheet named "OT" then If .Name = "OT" or InStr(1, .Name, "OT (", vbTextCompare) = 1 Then -- Regards, Tom Ogilvy "Dave Peterson" wrote in message ... Maybe you can just search for more of the name: If InStr(1, .Name, "OT (", vbTextCompare) Then KimberlyC wrote: Hi.. Below is part of some code I'm running.. This part: InStr(1, .Name, "OT", vbTextCompare) Call PrintareaOT2 is running when the "Other Deductions" workheet is active.. so I am asumming it's picking up the OT in the Other Deductions name. Is there a way to have this code check the sheet's name. The reason for not identifying the exact names of the sheets is because there can be multiple sheets with the same name ...they just have numbers after them.... like Other Deductions (2).. and so on ... and OT (2) and so on... *********************** With ActiveSheet If InStr(1, .Name, "OT", vbTextCompare) Then Call PrintareaOT2 End If If InStr(1, .Name, "Other Deductions", vbTextCompare) Then Call PrintareaDeductions2 End If End With As Always.. thanks in advance!! Kimberly -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom!
That did the trick.. :) "Tom Ogilvy" wrote in message ... An added thought: If you also have a sheet named "OT" then If .Name = "OT" or InStr(1, .Name, "OT (", vbTextCompare) = 1 Then -- Regards, Tom Ogilvy "Dave Peterson" wrote in message ... Maybe you can just search for more of the name: If InStr(1, .Name, "OT (", vbTextCompare) Then KimberlyC wrote: Hi.. Below is part of some code I'm running.. This part: InStr(1, .Name, "OT", vbTextCompare) Call PrintareaOT2 is running when the "Other Deductions" workheet is active.. so I am asumming it's picking up the OT in the Other Deductions name. Is there a way to have this code check the sheet's name. The reason for not identifying the exact names of the sheets is because there can be multiple sheets with the same name ...they just have numbers after them.... like Other Deductions (2).. and so on ... and OT (2) and so on... *********************** With ActiveSheet If InStr(1, .Name, "OT", vbTextCompare) Then Call PrintareaOT2 End If If InStr(1, .Name, "Other Deductions", vbTextCompare) Then Call PrintareaDeductions2 End If End With As Always.. thanks in advance!! Kimberly -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Possible to refer to a sheet's object name ? | Excel Worksheet Functions | |||
Printing Sheet's Name | Excel Discussion (Misc queries) | |||
How to copy a sheet's formatting from one xls to another? | Excel Discussion (Misc queries) | |||
how to get sheet's number it's name | Excel Discussion (Misc queries) | |||
Sheet's Name | Excel Programming |