Concatenate and bold - Excel 2007

preqin

Board Regular
Joined
Mar 15, 2005
Messages
83
I have a simple concatenate in Excel...

=CONCATENATE(A1, ", ", A2)

Which produces:

This is, my text

Now, I want 'my text' i.e. the contents of A2 to be in bold.

I've played with the TEXT() function before, as per this page:
http://www.techonthenet.com/excel/formulas/text.php

To get Excel to play nicely with date formats and stuff, however, my research has come to a dead end with Bold/Italic - with everyone suggesting that VBA is the only solution.

As I don't feel overly comfortable using VBA is there any other solution? (If not, is this a VBA 101 task or an advanced task?)
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Not particularly difficult in VBA, but IMHO it's off the end of the "effort applied vs. benefit achieved" scale!

Hold on, I'll try it while I have a brew......
 
Last edited:
Upvote 0
It's not me that wants it to be bold, but it IS me who has to try and do it... put it that way ;)

How would I go about this then? - Can someone give me a fairly basic guide?
 
Upvote 0
Code:
Sub BoldPartText()
Dim Part1Len, Part2Len, DividerLen As Integer
Dim Divider As String
Part1Len = Len(Range("A1")) + 1
Part2Len = Len(Range("A2"))
Divider = ", "
DividerLen = Len(Divider)

Range("A3") = Range("A1") & Divider & Range("A2")
With Range("A3").Characters(Start:=Part1Len + DividerLen, Length:=Part2Len).Font
        .FontStyle = "Bold"
End With
End Sub
 
Upvote 0
Thanks Yard, I just gave that a try but I could not get it to work.

I right clicked sheet one and went to view code and pasted in your code.

I then typed some text in to A1 and A2

In A3 I tried my concatenate as specified in the first post with teh ", " as I see you have used this as part of your code, however, A3 was simply the concatenate of both cells, and didnt bold anything - regardless of whether the original cells were bolded or not...

What am I doing wrong!?
 
Upvote 0
You need to put the code in a normal Module, NOT the worksheet code.

From Excel, hit Alt+F11.
On the left, right-click the sheet you are working on and Insert>Module.
PAste the code into that new window.
Now run it.
 
Upvote 0
Cool, I have that working now, thanks,

You're gonna go bonkers now, but I tinkered with it so I could change where it looks and where it places the results for a more realistic application than my example... however, how can I swap around the part which gets bolded to the first part?!

Code:
With Range("C1").Characters(Start:=Part1Len + DividerLen, Length:=Part2Len).Font
        .FontStyle = "Bold"

I gather it involves editing part of that statement, however, I am not sure which, and some trial and error has resulted in just error thus far!
 
Upvote 0
Should be simple to break down.

Part1Len is the first part of the concatentation. In the resulting value, it starts at character 1 and goes as far as there are characters in A1.

So, Part1Len = the length of the A1 string

So change your statement to

Code:
With Range("C1").Characters(Start:=1, Length:=Part1Len).Font
        .FontStyle = "Bold"

The Start:=1 tells it to begin from the 1st character, and the Length:=Part1Len tells it to apply the following instruction (i.e. Bold) to however many characters it found in cell A1.

Easy!
 
Upvote 0
I kinda sussed that out, the issue was then (I think) how I stick the other bits to that part of the string:

Code:
With Range("C1").Characters(Start:=1, Length:=Part1Len).Font
        .FontStyle = "Bold"

Makes sense, so I thought sticking the other bits on should just be a case of adding them to the end of the string:

Code:
With Range("C1").Characters(Start:=1, Length:=Part1Len).Font
        .FontStyle = "Bold"+ DividerLen, Length:=Part2Len

Failed though... I think it's a brackets issue, but I did try putting brackets around the whole lot (i.e. from the 's' of characters and the n of 'len' a the end) and that failed too!

Quite annoying as I'm usually OK at seeing what something is doing and adapting it!!
 
Upvote 0

Forum statistics

Threads
1,212,938
Messages
6,110,771
Members
448,297
Latest member
cocolasticot50

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top