View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Driscol[_2_] Mark Driscol[_2_] is offline
external usenet poster
 
Posts: 75
Default Replace left header

Option Explicit

Sub LeftHeader()

Dim strLeftHeader As String
Dim strTemp As String

strLeftHeader = ActiveSheet.PageSetup.LeftHeader

' If header contains Chr(10), there is more than one line in header
strTemp = Replace(strLeftHeader, Chr(10), "", 1, -1)

If Len(strTemp) = Len(strLeftHeader) Then
ActiveSheet.PageSetup.LeftHeader = strLeftHeader & Chr(10) _
& Range("A2").Value
End If

End Sub


Mark


GregR wrote:
I have a left header in all my project documents. What I want is macro
code that if the header has two lines, exit the macro, no change. If
however it has only one line, I want it to keep that line and add
another line with Range("A2") value. Any help appreciated. TIA

Greg