Ask Experts Questions for FREE Help !
Ask
    jakester's Avatar
    jakester Posts: 582, Reputation: 165
    Senior Member
     
    #1

    Aug 26, 2010, 02:07 PM
    VBA Question regarding Headers
    Ok, so here's my problem -

    I'm trying to customize a Header to be displayed in different workbooks. I want the Header to contain the name of the Worksheet as well as the current year. The header will read this way:

    Month of August 2010

    For the purposes of my code, I have the following code in my macro where I have manually typed in the year:

    With ActiveSheet.PageSetup
    .LeftHeader = "&""Arial,Bold""&12Month of &A 2010"
    .CenterHeader = ""
    .RightHeader = _
    "
    .RightHeader = _
    ""Arial,Bold""Report Date and Time:&""Arial,Regular"" &D &T"
    .LeftFooter = "&""Arial,Bold""Page &P of &N"
    End With

    However, I'd like to make the year dynamic and one way I have thought to do that is by take a cell from the Summary Worksheet of my workbook and take the Left 4 characters from cell A1, and return that value to the Left Header to concatenate the above sequence with the returned Year value:

    .LeftHeader = "&""Arial,Bold""&12Month of &A" & returnValue

    I get lost in the code when trying to set the Dim returnValue as String and referencing the Summary!A19 code, taking the Left(Summary!A19,4) and returning that value.

    Any ideas?

    Thanks.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

    Aug 27, 2010, 11:06 AM

    Maybe this:

    Code:
       .LeftHeader = "&""Arial,Bold""&12Month of &[A] " & Left(Sheets("Summary").Range("A19"), 4)

    Or even:
    Code:
       .LeftHeader = "&""Arial,Bold""&12Month of &[A] " & Year(Date)

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search


Check out some similar questions!

Remove headers above cabinets [ 3 Answers ]

I am wanting to remove the headers above my cabinets. Does that have anything to do with holding the cabinets up? I want to do this to have the space above the cabinets open. We are getting ready to resurface to cabinets and put new counter tops on. My kitchen is stuck in the 70's.

Headers and gable roofs [ 0 Answers ]

I am adding a 20 foot extion on the gable side with no 2nd story. I am putting in 15 feet of gliding doors on the gable side with a 3.5" x 9.5" by 10' power lam header/beam. Is this an overkill and if so, what is your recommendation. PS no supports or heavy duty mullions imbetween the 4 glass...

Spacing headers [ 3 Answers ]

When spaceing headers for a 2x4 stud wall you use a 1/2 piece of plywood. What is the best way when using 2x6's for studs Thanks for your time!

CGI for Apache - Premature end of script headers [ 13 Answers ]

I have a post form on my Web site in Common Gateway Interface (CGI) but when people click in order to post it, the message Premature end of script headers: mailform.cgi appears. If you'd like to see what I'm talking about please go to this page : http://www.accesss.net/pnjoindre.html. How can I...


View more questions Search