+ Reply to Thread
Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    07-28-2009
    Location
    York, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Fonts and Concatenate

    Hi, I'm trying to use concatenate to create a title of a graph as that the total variance month by month without having to manually update.

    However, we're wanting the figures in a smaller font and italic but it seems its an all or nothing font setting.

    Is it possible to have part of the concatenate a different font etc and if so, how?
    D

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Fonts and Concatenate

    So are you saying you're using a Formula to generate the physical Chart Title or are you putting the description into a standard cell ?
    Basically speaking it is not possible to use a Formula in a cell and apply different formats to different sections of the cell, in order to do that the cell entry needs essentially to be "value only" (ie no formula)... in general for the value to then be dynamic you would need to use VBA... if you're referring to the Chart Title itself I have even less knowledge as to whether or not you can even use VBA to apply different formats to specific elements of the Title itself... let us know exactly what you're doing and what you're concatenating etc... ie which cells, when/how they alter etc...

  3. #3
    Registered User
    Join Date
    07-28-2009
    Location
    York, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Fonts and Concatenate

    I'm linking the title to a particular cell which is where the concatenate formula is:
    =CONCATENATE(I73,CHAR(13),"Total Variance ","£",ROUND(O38/1000,0),"k"," ","Percentage"," ",O41,"%")

    The consensus we had here was it may not be possible but I just dont want to use text boxes if I can avoid it!

  4. #4
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Fonts and Concatenate

    Apologies for delay...

    I was doing some testing and for whatever reason I'm unable to apply multiple formats to the Chart Title characters via VBA... I've moved this to the Charts Forum - hopefully Andy (Pope) will see this and respond accordingly.

  5. #5
    Registered User
    Join Date
    07-28-2009
    Location
    York, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Fonts and Concatenate

    Thank you!

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    10,938

    Re: Fonts and Concatenate

    You can not format parts of the result of a formula.

    You will need to use VBA to set the text and format the required parts.
    In the attached the formula is in C2 with the 3 components in A1:A3

    The following located and formats the 2nd and 3rd components.

    Code:
    Sub ChartTitle()
    
        Dim strText As String
        Dim lngStart As Long
        Dim lngEnd As Long
        
        With ActiveSheet.ChartObjects(1).Chart
            .HasTitle = True
            .ChartTitle.Text = Range("C2").Value
            .ChartTitle.Font.Size = 20
            
            strText = .ChartTitle.Text
            lngStart = InStr(strText, "Total Variance") + Len("Total Variance") + 1
            lngEnd = InStr(strText, "Percentage")
            .ChartTitle.Characters(lngStart, lngEnd - lngStart).Font.Size = 8
            
            lngStart = lngEnd + Len("Percentage") + 1
            lngEnd = Len(strText)
            .ChartTitle.Characters(lngStart, lngEnd - lngStart + 1).Font.Size = 8
            
        End With
    End Sub
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  7. #7
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Fonts and Concatenate

    Hi Andy, yes, this approach doesn't work for me in XL2007 ... ie the tweaked format is applied to the entire title as opposed to just the sub-selection of characters in the string.... is it a version specific difference or am I being a dunce ?

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    10,938

    Re: Fonts and Concatenate

    Will investigate further for '07 solution.
    Cheers
    Andy
    www.andypope.info

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    10,938

    Re: Fonts and Concatenate

    Looks like a bug in xl2007. The formatting is applied to all text in the specified range.

    So you will need a embedded textbox and then this code.

    Code:
    Sub ChartTitle()
    
        Dim strText As String
        Dim lngStart As Long
        Dim lngEnd As Long
        Dim objTF2 As TextFrame2
        Dim shpTemp As Shape
        
        Set shpTemp = ActiveSheet.ChartObjects(1).Chart.Shapes(1)
        With shpTemp
            Set objTF2 = .TextFrame2
            With objTF2.TextRange
                .Font.Size = 20
                strText = Range("C2").Value
                .Characters.Text = strText
                
                lngStart = InStr(strText, "Total Variance") + Len("Total Variance") + 1
                lngEnd = InStr(strText, "Percentage")
                .Characters(lngStart, lngEnd - lngStart).Font.Size = 8
                
                lngStart = lngEnd + Len("Percentage") + 1
                lngEnd = Len(strText)
                .Characters(lngStart, lngEnd - lngStart + 1).Font.Size = 8
                
            End With
        End With
    
    End Sub
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  10. #10
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Fonts and Concatenate

    Andy, thanks for that, reassured to know I wasn't being a "muppet"... this time

  11. #11
    Forum Contributor
    Join Date
    04-03-2007
    Location
    Auckland, New Zealand
    MS-Off Ver
    2007
    Posts
    137

    Re: Fonts and Concatenate

    If the chart is embedded in a worksheet you could always try a less elegant approach...

    Set the Chart Area to 'No Fill' and format the cells behind however you like...

    Adjust column widths and have a cell for each differently formatted data in the 'Chart Title'.

    As I said, not elegant, but possibly easier for the non-VBA Excel user.

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.2.0