Make only specific text in a cell bold

Attempting to create part of a string in a Userform textbox proved not yet possible in Excel up to version 2016, so an alternative function was created for a client to allow them to copy a string of text from a userform and in the process cause specific sections to be set to bold. The text is held in a cell on the worksheet, and a copy button created on the form next to the textbox. This then sets a chain reaction to ensure that all words that are in a list are subsequently turned bold in a particular cell before the copy function grabs the text from that cell, ready to paste elsewhere.

We use the Instr function, the Len function and the Characters function to determine where the word starts, how long it is and therefore how many characters to turn bold.

This script was used to test the viability of the function and proved to be useful and very quick, fulfilling the requirements of the clients project. We adapted it to fit their project and also allow them to create the list of desired words or phrases that needed to be set to bold.

Feel free to use or adapt the code for your own use or contact us for further assistance.

Sub Button1_Click()

For r = 1 To 2

x = ActiveSheet.Range("D" & r)
xl = Len(ActiveSheet.Range("D" & r))

For n = 1 To 13

y = InStr(1, ActiveSheet.Range("A" & n), x)
ActiveSheet.Range("A" & n).Characters(y, xl).Font.Bold = True

Next n

Next r

End Sub

Contact us for some advice and guidance on how your Excel development could be created and start helping your business straight away. Contact Us
the web designer group uk
the webdesigner group logo

Close Button

Web Site Designed by

The Web Designer Group