PDA

View Full Version : Solved: Testing the Left Header



Djblois
04-03-2007, 12:34 PM
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 -

leftHeaderText = "Grocery Division"
If ActiveSheet.PageSetup.LeftHeader = leftHeaderText Then

If ActiveSheet.PageSetup.LeftHeader = "Grocery Division"

If ActiveSheet.PageSetup.LeftHeader = "&""Arial,Bold""&10Grocery Division"

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

mvidas
04-03-2007, 12:45 PM
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):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
Matt

Djblois
04-03-2007, 02:04 PM
Thank you for your help, it worked now