Consulting

Results 1 to 3 of 3

Thread: How to display Variable in xl custom header

  1. #1

    Question How to display Variable in xl custom header

    I am new to VBA and am trying to display the value of a variable (string format) in a custom excel header. The string variable is a month and I would like it to appear in the header. So far I've had no success.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Off the tops

    [vba]

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    With ActiveSheet.PageSetup

    .LeftHeader = myvar
    End With
    End Sub
    [/vba]

    This is workbook event code.
    To input this code, right click on the Excel icon on the worksheet
    (or next to the File menu if you maximise your workbooks),
    select View Code from the menu, and paste the code
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thanks for the help. It makes sense now that I see it.

    Brew4Chuck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •