Consulting

Results 1 to 9 of 9

Thread: Solved: Dynamic Custom Header/Footer

  1. #1
    VBAX Regular
    Joined
    Feb 2011
    Posts
    26
    Location

    Solved: Dynamic Custom Header/Footer

    Im working on some code and i would like to have and input box pop up and have the user input a value from that value i would like to input the value in the left header. I also would like to adjust the formatting to bold and #12 font Arial.

    [vba]LH1 = Application.InputBox("Enter the Account Number i.e. 123456789").LeftHeader = LH1[/vba]

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    [VBA]LH1 = Application.InputBox("Enter the Account Number i.e. 123456789")

    Worksheets("Sheet1").PageSetup.LeftHeader = "&B&""Arial""&12" & LH1
    [/VBA]
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Regular
    Joined
    Feb 2011
    Posts
    26
    Location
    Quote Originally Posted by mancubus
    [vba]LH1 = Application.InputBox("Enter the Account Number i.e. 123456789")

    Worksheets("Sheet1").PageSetup.LeftHeader = "&B&""Arial""&12" & LH1
    [/vba]
    This works well, but it does not seem to like numerical strings. I tryed typing in a numerical string of numbers in the inputbox and nothing shows up in the left header on the other hand text works perfectly.

  4. #4
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    try:
    [VBA]Worksheets("Sheet1").PageSetup.LeftHeader = "&B&""Arial""&12 " & LH1[/VBA]
    added a space after &12


    or
    [VBA]Worksheets("Sheet1").PageSetup.LeftHeader = "&""Arial,Bold""&12 " & LH1[/VBA]
    Last edited by mancubus; 09-28-2011 at 02:47 PM.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  5. #5
    VBAX Regular
    Joined
    Feb 2011
    Posts
    26
    Location
    Thanks that works Perfectly!

  6. #6
    VBAX Regular
    Joined
    Apr 2011
    Location
    Kocaeli
    Posts
    21
    Location
    Hello Mancubus,

    How can we leave one blank line between Left Header and Mid Header? I mean Right and Left Headers will be in the same line, but there will be a blank line between that line and that of the Mid Header.

    Thanks in advance...

  7. #7
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    hi capungo.

    try this.
    [vba]
    With Worksheets("Sheet1").PageSetup
    .LeftHeader = "&""Arial,Bold""&12 " & "This is Left Header"
    .CenterHeader = "&""Tahoma,Bold""&14 " & vbCrLf & "This is Center Header"
    .RightHeader = "&""Verdana,Bold""&12 " & "This is Right Header"
    End With
    [/vba]
    Last edited by mancubus; 10-14-2011 at 12:14 AM.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  8. #8
    VBAX Regular
    Joined
    Apr 2011
    Location
    Kocaeli
    Posts
    21
    Location
    Hello Mancubus,

    Works very fine. Thank you very much...

  9. #9
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    you're wellcome...
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

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