Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Replace left header
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Only change left header on all worksheets | Excel Discussion (Misc queries) | |||
How do I left justify center section header | Excel Discussion (Misc queries) | |||
header in right or left margin? | Excel Discussion (Misc queries) | |||
Left/Right Margins in Header/Footer | Excel Discussion (Misc queries) | |||
Header/Left margin | Excel Programming |