Consulting

Results 1 to 3 of 3

Thread: Solved: Testing the Left Header

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Solved: Testing the Left Header

    I am trying to run code if the text in the Left Header is Grocery Division and I can't get it to work. Here are the different ways I have tried -

    [VBA]leftHeaderText = "Grocery Division"
    If ActiveSheet.PageSetup.LeftHeader = leftHeaderText Then[/VBA]

    [VBA]If ActiveSheet.PageSetup.LeftHeader = "Grocery Division"[/VBA]

    [VBA]If ActiveSheet.PageSetup.LeftHeader = "&""Arial,Bold""&10Grocery Division"[/VBA]

    The last one I tried because that is the formating I set.

  2. #2
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Hi,

    What was wrong with that last one (aside from putting "Then" at the end of the line)?

    However, you can do what you had first using something InStr (i included something to set the left header as well for my testing):[vba]Sub example()
    ActiveSheet.PageSetup.LeftHeader = "&""Arial,Bold""&10Grocery Division"

    leftHeaderText = "Grocery Division"

    If InStr(1, ActiveSheet.PageSetup.LeftHeader, leftHeaderText, vbTextCompare) > 0 Then
    MsgBox "Yes"
    Else
    MsgBox "No"
    End If
    End Sub[/vba]
    Matt

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Thank you for your help, it worked now

Posting Permissions

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