Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 07-29-2009, 04:11 AM
Dave Harbottle Dave Harbottle is offline
Registered User
 
Join Date: 28 Jul 2009
Location: York, England
MS Office Version:Excel 2003
Posts: 3
Dave Harbottle is becoming part of the community
Fonts and Concatenate

Please Register to Remove these Ads

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
Reply With Quote
  #2  
Old 07-29-2009, 04:24 AM
DonkeyOte's Avatar
DonkeyOte DonkeyOte is offline
Forum Guru
 
Join Date: 22 Oct 2008
Location: Suffolk, UK
MS Office Version:2002 & 2007
Posts: 13,645
DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute
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...
Reply With Quote
  #3  
Old 07-29-2009, 05:18 AM
Dave Harbottle Dave Harbottle is offline
Registered User
 
Join Date: 28 Jul 2009
Location: York, England
MS Office Version:Excel 2003
Posts: 3
Dave Harbottle is becoming part of the community
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!
Reply With Quote
  #4  
Old 07-29-2009, 08:26 AM
DonkeyOte's Avatar
DonkeyOte DonkeyOte is offline
Forum Guru
 
Join Date: 22 Oct 2008
Location: Suffolk, UK
MS Office Version:2002 & 2007
Posts: 13,645
DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute
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.
Reply With Quote
  #5  
Old 07-29-2009, 08:50 AM
Dave Harbottle Dave Harbottle is offline
Registered User
 
Join Date: 28 Jul 2009
Location: York, England
MS Office Version:Excel 2003
Posts: 3
Dave Harbottle is becoming part of the community
Re: Fonts and Concatenate

Thank you!
Reply With Quote
  #6  
Old 07-29-2009, 08:51 AM
Andy Pope's Avatar
Andy Pope Andy Pope is online now
Forum Guru
 
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,223
Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding
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
File Type: xls 693453.xls (25.5 KB, 2 views)
__________________
Cheers
Andy
www.andypope.info
Reply With Quote
  #7  
Old 07-29-2009, 08:56 AM
DonkeyOte's Avatar
DonkeyOte DonkeyOte is offline
Forum Guru
 
Join Date: 22 Oct 2008
Location: Suffolk, UK
MS Office Version:2002 & 2007
Posts: 13,645
DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute
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 ?
Reply With Quote
  #8  
Old 07-29-2009, 09:00 AM
Andy Pope's Avatar
Andy Pope Andy Pope is online now
Forum Guru
 
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,223
Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding
Re: Fonts and Concatenate

Will investigate further for '07 solution.
__________________
Cheers
Andy
www.andypope.info
Reply With Quote
  #9  
Old 07-29-2009, 11:49 AM
Andy Pope's Avatar
Andy Pope Andy Pope is online now
Forum Guru
 
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,223
Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding
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
File Type: xlsm 693453a.xlsm (20.3 KB, 3 views)
__________________
Cheers
Andy
www.andypope.info
Reply With Quote
  #10  
Old 07-29-2009, 11:53 AM
DonkeyOte's Avatar
DonkeyOte DonkeyOte is offline
Forum Guru
 
Join Date: 22 Oct 2008
Location: Suffolk, UK
MS Office Version:2002 & 2007
Posts: 13,645
DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute DonkeyOte has a reputation beyond repute
Re: Fonts and Concatenate

Andy, thanks for that, reassured to know I wasn't being a "muppet"... this time
Reply With Quote
  #11  
Old 07-30-2009, 06:40 AM
Jbentley Jbentley is offline
Forum Contributor
 
Join Date: 03 Apr 2007
Location: Auckland, New Zealand
MS Office Version:2007
Posts: 121
Jbentley has been very helpful
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.
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump