View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GregR GregR is offline
external usenet poster
 
Posts: 246
Default Replace left header

Mark, thank you very much, exactly what I wanted

Greg
Mark Driscol wrote:
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