Margins control to VBA code

R

retseort

I need some help. The code below populates the header and footer
information from cells on what I named the header page.

I need this code to also adjust the top margin to 1.44" on the sheet
when the header is updated.

Thanks in advance!


Sub SetHeader(sh As Worksheet)
Dim lStr As String
Dim rStr As String
Dim dStr As String

With Worksheets("HeaderPage")

lStr = .Range("J2") & vbCr & .Range("J3") & vbCr &
..Range("J4")
rStr = .Range("M2") & vbCr & .Range("M3") & vbCr & .Range("M4")
& vbCr & .Range("M5") & vbCr & .Range("M6")
dStr = "&6" & Range("W1") & vbCr & .Range("W2") & vbCr &
..Range("W3") & vbCr & .Range("W4")
End With

With sh.PageSetup
..LeftHeader = lStr
..RightHeader = rStr
..CenterFooter = dStr


End With
End Sub
 
T

tiah

record a new macro
set your margin to 1.44
go take a look at the code
copy the line

voilà !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top