Formatting 2 strings in cell in different ways

ardykav

Board Regular
Joined
Oct 18, 2015
Messages
172
Office Version
  1. 365
Platform
  1. Windows
I have 2 columns, Column A has a regularly formatted first name. Calibri 11. It is also a look up formula from another sheet.

Column B is Surname which is also a lookup formula from another sheet but I have used the Upper function on it to make it all upper case and also bolded the column.

I am wondering is there any way to have all of these in one cell with the formatting preserved?

I suppose the hard part is just getting the bold part on the surname

All help greatly appreciated
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
If each cell in columns A:B contains one word only :
VBA Code:
Sub v()
Dim Rng As Range, cel As Range
Set Rng = Range("C2:C" & Cells(Rows.Count, "A").End(3).Row)
Rng = Evaluate(Rng.Offset(0, -2).Address & " & "" "" & " & Rng.Offset(0, -1).Address)
For Each cel In Rng
   cel.Characters(InStr(1, cel, " ")).Font.Bold = True
Next
End Sub
 
Upvote 0
thanks but they might have more than one if people have double barrell names and in some cases triple. Is there any way of adpating to just take whatever is in B and Bold it after the merge is done?

If each cell in columns A:B contains one word only :
VBA Code:
Sub v()
Dim Rng As Range, cel As Range
Set Rng = Range("C2:C" & Cells(Rows.Count, "A").End(3).Row)
Rng = Evaluate(Rng.Offset(0, -2).Address & " & "" "" & " & Rng.Offset(0, -1).Address)
For Each cel In Rng
   cel.Characters(InStr(1, cel, " ")).Font.Bold = True
Next
End Sub
 
Last edited:
Upvote 0
It should work if column B has more than one word but needs revising if column A has more than one.
 
Upvote 0
I think I have a workaround, what if it was 3 Columns, A was first Name only just one word, column B was the other names and then the final column C was the surname to be bolded that may contain 2 words like "De Blanc" ? Would that make it easier?

If each cell in columns A:B contains one word only :
VBA Code:
Sub v()
Dim Rng As Range, cel As Range
Set Rng = Range("C2:C" & Cells(Rows.Count, "A").End(3).Row)
Rng = Evaluate(Rng.Offset(0, -2).Address & " & "" "" & " & Rng.Offset(0, -1).Address)
For Each cel In Rng
   cel.Characters(InStr(1, cel, " ")).Font.Bold = True
Next
End Sub
 
Upvote 0
With your original formulas in columns A & B, this should put what you want in column C, no matter how many words are in either column.

VBA Code:
Sub JoinAndBoldLast()
  Dim c As Range
  
  Application.ScreenUpdating = False
  For Each c In Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row)
    With c
      .Value = .Offset(, -2).Value & " " & .Offset(, -1).Value
      .Characters(Len(.Offset(, -2).Value) + 2).Font.Bold = True
    End With
  Next c
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
That Sir is outstanding, worked absolutely perfectly thanks so much to both of you for taking the time to write this

With your original formulas in columns A & B, this should put what you want in column C, no matter how many words are in either column.

VBA Code:
Sub JoinAndBoldLast()
  Dim c As Range
 
  Application.ScreenUpdating = False
  For Each c In Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row)
    With c
      .Value = .Offset(, -2).Value & " " & .Offset(, -1).Value
      .Characters(Len(.Offset(, -2).Value) + 2).Font.Bold = True
    End With
  Next c
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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