Header/Footer

L

LB79

Does anyone know of a way to put a cell value in headers and footers?
need for the User name to show when they print - i can get the name i
the sheet but would prefer it in the header.
Thank
 
B

Bob Phillips

Put this code in the Thisworkbook code module

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
ActiveSheet.PageSetup.LeftFooter = Range("A1")
End If
End Sub
 
G

Gord Dibben

LB

Should be able to get UserName directly into header/footer.

Sub PathInFooter()
'adjust to suit
ActiveSheet.PageSetup.RightFooter = ActiveWorkbook.FullName & " " & _
ActiveSheet.Name & " " & Application.UserName & " " & Date
End Sub

OR if username is in a cell.........

Sub CellInFooter()
With ActiveSheet
.PageSetup.CenterFooter = .Range("A1").text
End With
End Sub

Gord Dibben Excel MVP
 
Top