+ Reply to Thread
Results 1 to 4 of 4

Help with code that finds a sheet's name

  1. #1
    KimberlyC
    Guest

    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. #2
    Dave Peterson
    Guest

    Re: 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. #3
    Tom Ogilvy
    Guest

    Re: 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" <petersod@verizonXSPAM.net> wrote in message
    news:42D185E2.EC341D58@verizonXSPAM.net...
    > 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. #4
    KimberlyC
    Guest

    Re: Help with code that finds a sheet's name

    Thanks Tom!
    That did the trick..

    "Tom Ogilvy" <twogilvy@msn.com> wrote in message
    news:eCmF4IZhFHA.3540@TK2MSFTNGP14.phx.gbl...
    > 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" <petersod@verizonXSPAM.net> wrote in message
    > news:42D185E2.EC341D58@verizonXSPAM.net...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1