I would like to use a macro to bold the word "Actual" in cell named "VMDate". How can I do this. The cell also contains other text that I wish to leave alone.
Sub Example()
Const sTOFIND As String = "actual"
Dim lFirstChar As Long
With Range("VMDate")
lFirstChar = InStr(1, .Value, sTOFIND, vbTextCompare)
If lFirstChar Then
.Characters(lFirstChar, Len(sTOFIND)).Font.Bold = True
End If
End With
End Sub
Well that code worked, but since I have code that enters the text into that cell, this code only works the 1st time I run the macro. But using the recorder and editing the output I came up with this, which works fine. Thank you.
Code:
With Range("VMDate").Characters(Start:=1, Length:=6).Font
.Bold = True
End With
With Range("VMDate").Characters(Start:=7, Length:=13).Font
.Bold = False
End With
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.