Highlighting a portion of a cell

timbo.hobo

New Member
Joined
Nov 21, 2005
Messages
5
Hi,
I need to make only the last few characters in a cell bold font (ie: turning "12345" to "12345")

Is this possible with VB code?

Thanks.
Tim.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Good evening timbo.hobo

This code will do the trick. BUT...

it won't work on numeric strings, only text strings.

Sub Test()
ActiveCell.Characters(Start:=3, Length:=3).Font.Bold = True
End Sub

HTH

DominicB
 
Upvote 0
Hello Tim,
DominicB's code will make the 3rd, 4th & 5th characters bold, no matter how many characters there are in the active cell.

If you're looking to make the last two characters bold, no matter how many characters there are, then perhaps something like this instead.
Code:
Sub Demo()
NumChr = Len(ActiveCell)
With ActiveCell.Characters(Start:=NumChr - 1, Length:=2).Font
    .FontStyle = "Bold"
End With
End Sub
However, as DominicB pointed out, this will only work on text entries, or numbers formatted as text.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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