+ Reply to Thread
Results 1 to 8 of 8

How to control font size in excel custom header in VBA

  1. #1
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    How to control font size in excel custom header in VBA

    I have a macro that I use to enter a date from a cell in the worksheet to the left header in the custom header section.

    This is the code and it works almost as I want:

    Please Login or Register  to view this content.
    The problem is the date that I plug in to cell CA3 does appear in the header but the font size is 10 and I want to change it to 18 - I also want to make it bold. I've tried various
    options which I've been finding on google but none have worked. Here is some code I used which doesn't give me what I want.

    Please Login or Register  to view this content.
    Thanks for any help you can give with proper syntax

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How to control font size in excel custom header in VBA

    Please Login or Register  to view this content.
    Last edited by shg; 06-28-2016 at 03:22 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,173

    Re: How to control font size in excel custom header in VBA

    Try

    ActiveSheet.PageSetup.LeftHeader = "&""-,Bold""&18" & Range("A3")

    One way to determine the code is to "record macro".

  4. #4
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to control font size in excel custom header in VBA

    Hi John,

    Thanks for your reply. I did try the code you sent and it worked except the date appeared as "/24/2016" even though cell CA3 contains "06/24/2016".

    Also the bold 18 was about 2.5 inches high and bled over into the print of the first several rows and I had to reduce it and put it as Bold""&1"

    Here is the code I have at present:
    Please Login or Register  to view this content.
    I'm confused as to why the font size is so different.

    By the way I tried recording a macro but got similar results.

    Thanks again for your help.

  5. #5
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to control font size in excel custom header in VBA

    Thanks for your help.

    I made the change per your code but there are 2 problems.

    1) The font size is an issue - when I put &18 it appears about 4 times as large and covers about 4 rows of the printed document. When I put &1 it looks approximately the right size - very confusing.
    2) The value I have in cell CA3 is: 06/24/2016 however what appears in the LeftHeader is: /24/2016 - the month does not appear.

    Here is the code I ran and it is the only code line in my macro:

    Please Login or Register  to view this content.


    *** FYI - I know I can use the date icon manually in the header but I'm going to use this routine to change multiple worksheets and prefer not to have to change them all manually.

    Could this be a problem in excel 2016?


    Thanks again

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How to control font size in excel custom header in VBA

    Oops:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to control font size in excel custom header in VBA

    shg,

    Thanks for your help - that did it and gave exactly the right results. Good Job!!!

    I will close the thread now.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How to control font size in excel custom header in VBA

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Header date font size
    By jokris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2016, 04:15 PM
  2. Replies: 0
    Last Post: 12-10-2010, 09:46 PM
  3. format different font size in header
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2010, 11:16 AM
  4. Font size in header
    By Steven811 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2010, 10:40 AM
  5. Increase header font size
    By Steven811 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-22-2010, 06:29 AM
  6. [SOLVED] Header Font size
    By Mike Fogleman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2005, 09:05 PM
  7. Programatically changing font size in custom header
    By Katherine in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2005, 09:06 AM

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