Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Help with code that finds a sheet's name


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with code that finds a sheet's name

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with code that finds a sheet's name

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Help with code that finds a sheet's name

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to refer to a sheet's object name ? kittronald Excel Worksheet Functions 1 August 23rd 11 11:30 PM
Printing Sheet's Name Gingit Excel Discussion (Misc queries) 7 November 10th 08 09:13 AM
How to copy a sheet's formatting from one xls to another? John Dalberg Excel Discussion (Misc queries) 2 October 16th 07 04:18 PM
how to get sheet's number it's name alekm Excel Discussion (Misc queries) 2 January 30th 07 11:32 AM
Sheet's Name Martín2626 Excel Programming 8 January 29th 04 02:51 PM


All times are GMT +1. The time now is 02:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"