Suppose we have text “Commerce and Excel hub” in Cell B3 like the example shown.
Now using VBA we want to change the font to bold only for word “Commerce” like the example shown.
You can use below code for the same.
Range("B3").Characters(Start:=1, Length:=8).Font.FontStyle = "Bold"
Explanation of Above Code line.
- Range(“B3”) is cell address
- Characters are letters in the cells
- The start is the position of the first letter for which we want to change the font
- Length is the position of the last letter for which we want to change the font
- .font .fontstyle=”bold” will help to change the font as per request (In this case we have selected bold)
- Test() is the name of the macro. Sub & End sub is to start and end the VBA code.