+ Reply to Thread
Results 1 to 2 of 2

Multiple Font Sizes In A Chart Title

  1. #1
    Registered User
    Join Date
    05-25-2010
    Location
    Yorktown, USA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Multiple Font Sizes In A Chart Title

    Hi all:

    I am using EXCEL 2007, and I am trying to change the font size of the 2nd line of a chart title.

    I ran a macro using EXCEL 2003 to see how this might be accomplished, but it did not work as it set the font size of the entire chart title to the value that was assigned to the 2nd line of the chart title.

    For reference purposes, I am including the Macro that works in EXCEL 2003, but does not work in EXCEL 2007 below.

    Any help would be greatly appreciated in providing code that provides 2 different font sizes for a chart title with multiple lines in EXCEL 2007.

    Thanks in advance for your help.

    VPI63
    ===========

    Sub ChangeChartTitleFontSize ()
    '
    'EXCEL 2003 Macro (Doesn't work in EXCEL 2007)
    'The Macro runs in EXCEL 2007, but sets the Font Size of The chart title to '16, which is Font size of the 2nd line of the chart title
    '
    Dim ChartTitle1 as string
    Dim ChartTitle2 as String
    Dim Lenght1 as Integer
    Dim Lenght2 as Integer

    ChartTitle1 = "This is the First Line With the Large Font"
    ChartTitle2 = "This is the 2nd Line"
    '
    Lenght1 = len(ChartTitle1)
    Lenght2 = Len(ChartTitle2)
    '
    ActiveChart.ChartTitle.Select
    Selection.Characters.Text = ChartTitle1 & Chr(10) & ChartTitle2
    Selection.AutoScaleFont = False
    With Selection.Characters(Start:=1, Length:=Length1).Font
    .Name = "Arial"
    .FontStyle = "Bold"
    .Size = 24
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    '.ColorIndex = xlAutomatic
    End With
    Selection.Characters.Text = ChartTitle1 & Chr(10) & ChartTitle2
    Selection.AutoScaleFont = False
    With Selection.Characters(Start:=Length1 + 1, Length:=Length2).Font
    .Name = "Arial"
    .FontStyle = "Bold"
    .Size = 16
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    End sub

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Multiple Font Sizes In A Chart Title

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ 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