+ Reply to Thread
Results 1 to 5 of 5

passing a variable to Page Header

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    passing a variable to Page Header

    my variable RefNum doesn't pass to the Page Header

    RefNum = InputBox("What is the Reference Number?")
    
        Sheets("Image").Select
            With ActiveSheet.PageSetup
                .LeftHeader = "&""Arial,Bold""&14RefNum"
            End With
    If I don't include the formatting info it works but I'd like it fomatted
    .LeftHeader = RefNum

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Carstowal,

    This will put the word "RefNum" followed by the RefNum value that was entered.

      RefNum = InputBox("What is the Reference Number?")
    
        Sheets("Image").Select
            With ActiveSheet.PageSetup
                .LeftHeader = "&""Arial,Bold""&14" & "RefNum " & RefNum
            End With
    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686
    Thanks

    I didn't really want it to say RefNum & then the Reference Number

    but it seems like it needs something in between the "&14" and the variable, though, so I added this blank space & it works!

    .LeftHeader = "&""Arial,Bold""&14" & "  " & RefNum

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Carstowal,

    You are right about the space. It is needed to delimit the end of the format code from the text to display. I should have just given you this code, but thought you might want to label the reference number.

      RefNum = InputBox("What is the Reference Number?")
    
        Sheets("Image").Select
            With ActiveSheet.PageSetup
                .LeftHeader = "&""Arial,Bold""&14 " & RefNum
            End With
    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686
    Thanks for the explanation.
    I had tried every imaginable variation except a blank space.
    Thanks to you, now I know why!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1