Concatenate 2 cells while keeping their formatting?

c.clavin

Board Regular
Joined
Mar 22, 2011
Messages
123
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi guys, I'm having an issue where I really need 2 cells information (category and description) inside of the same cell (C2), but I need to have separate fonts and colors inside of it. Both font sizes can be 12.

I have tried formatting, using labels, everything, but it's not going to work. If you could please help me out on this I'd greatly appreciate it. I put an example of it below. Thanks!

Book5
ABC
1CATEGORYDESCRIPTIONFORMULA
2MODELF-150 Lightning
Sheet1
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
You cannot format part of a cell that has a formula.
 
Upvote 0
You cannot format part of a cell that has a formula.
Is there a way to use VBA? The problem is that my page is so tight I need to combine these two different cells into one.

Edit: What if I had the cells concatenated in another cell already and just wanted to make the first word a different color?
 
Last edited:
Upvote 0
You could do it with VBA, but you could not have a formula in the cell.
 
Upvote 0
You could do it with VBA, but you could not have a formula in the cell.
Hi Fluff, in the post below they seem to be able to do this while keeping the colors in it. Do you think there's a way to execute this code without the button approach?

 
Upvote 0
Hi Fluff, in the post below they seem to be able to do this while keeping the colors in it. Do you think there's a way to execute this code without the button approach?

The code at that link does not use a formula in the output cell... it is putting constants into the cell... and, as Fluff said, you can do it with VBA (like the link did), but you cannot have a formula in that cell (only constants like at your link). You would have to provide full details about what is being concatenated and exactly what that concatenation should look like, but it should be possible to create some event code that would act like a formula (concatenation that responds to changes in the cells that are being concatenated just like a formula would do). Let the forum know if you want to pursue this approach.
 
Upvote 0
The code at that link does not use a formula in the output cell... it is putting constants into the cell... and, as Fluff said, you can do it with VBA (like the link did), but you cannot have a formula in that cell (only constants like at your link). You would have to provide full details about what is being concatenated and exactly what that concatenation should look like, but it should be possible to create some event code that would act like a formula (concatenation that responds to changes in the cells that are being concatenated just like a formula would do). Let the forum know if you want to pursue this approach.
Thanks for your reply. I have this working minus the event code you're describing. Here's what I have so far. Could you help me so it updates dynamically? Thanks again!

Private Sub Worksheet_Change(ByVal Target As Range)

Dim i As Long
Dim First As Variant
Dim Second As Variant
Dim Both As Variant

Set First = Range("A200")
Set Second = Range("B200")
Set Both = Range("B21")

Application.EnableEvents = False

Both.Value = First.Value & " " & Second.Value

done = 0

For i = 1 To Len(Range("B21").Value)

If done = 0 Then

Both.Characters(i, 1).Font.Color = vbRed
Both.Characters(i, 1).Font.Name = "Calibri"

End If


If done = 1 Then

Both.Characters(i, 1).Font.Color = vbBlack
Both.Characters(i, 1).Font.Name = "Times New Roman"

End If

If Mid$(Both.Value, i, 1) = " " Then

done = 1

End If

Next

Application.EnableEvents = True

End Sub
 
Upvote 0
You are only talking about concatenating two cells (A200 and B200) and putting that concatenation in cell B21, correct? You are not talking about a range of cells to apply this to, correct?
 
Upvote 0
That’s correct. B200 is a formula, that TEXTJOIN’s multiple other cells. I guess because I’d a formula it looks static to the code and isn’t updating?
 
Upvote 0

Forum statistics

Threads
1,215,288
Messages
6,124,086
Members
449,141
Latest member
efex

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