Displaying alternate Words in BOLD in a Cell

NimishK

Well-known Member
Joined
Sep 4, 2015
Messages
684
Hi

I would like to Bold alternate words
for eg Name : MR.EXCEL Country : USA

Code:
Dim strName As String, strCountry As String, Dim mpStart As Long
    strName = "MR.EXCEL"
    strCountry = "USA"
    
With Worksheets("sheet5").Cells(14, 1)
          .Font.Bold = False
     .value = "Name : " & strName
     .value =  "Country : " & strCountry     '
     mpStart = InStr(.value, strName)
   If mpStart > 0 Then
     .Characters(mpStart, Len(strName)).Font.Bold = True
     .Characters(mpStart, Len(strCountry)).Font.Bold = True
      End If
 End With
I tried above only hiliting in bold is Mr. Excel and other remains without bold
MR.EXCEL and USA should be in bold
Thanks
NimishK
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Code:
Dim strName As String, strCountry As String
strName = "MR.EXCEL"
strCountry = "USA"
With Worksheets("sheet5").Cells(14, 1)
    .Font.Bold = False
    .Value = "Name : " & strName & " Country : " & strCountry
    .Characters(InStr(1, .Value, strName, 1), Len(strName)).Font.Bold = True
    .Characters(InStr(1, .Value, strCountry, 1), Len(strCountry)).Font.Bold = True
End With
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,545
Members
449,317
Latest member
chingiloum

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