I am building a template in Excel and I would like the phrase "6. Description Summary:" to be bold using VBA. The cell the phrase is located is not static so the code should be able to pick up the phrase anywhere within the range.
Currently the code makes the whole range A1:G100 bold
Here is what I have tried:
Set BoldRange = Range("A1:G100").Find("6. Description Summary:")
If Not (BoldRange Is Nothing) Then
BoldRange.Font.Bold = True
End If
Would appreciate it if you could let me know if there is a way to edit this code to make it bold only the specified text.
Update: The text is broken up into multiple cells so I am actually looking to only bold the specified string.
The code does what you want, I checked it myself. Set BoldRange = Range("A1:G100").Find("6. Description Summary:") returns the range where the string is found, and that is the only cell that is turned to bold. Check in your code if you are not manipulting the range somewhre else where you might be changing the whole range to bold. Below the code I used, just in case it helps (just yours into a Sub()):
Sub FindAndBold() Set BoldRange = Range("A1:G100").Find("6. Description Summary:") If Not (BoldRange Is Nothing) Then BoldRange.Font.Bold = True End If End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.