Post contents of a cell in the header/footer

M

MichaelRLanier

Is there a way to post the value of a cell in the header/footer of a
worksheet. For example, if A1 reflects a short text i.e. a business
name, can that name be made to show in a header/footer. Thanks.

Michael
 
D

Dave Peterson

You can use an event macro that fires when you print or print preview.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
with Worksheets("Somesheetnamehere")
.PageSetup.LeftFooter = .Range("A1").Text
End With
End Sub


This code goes in the ThisWorkbook module.

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)
 

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