Changing selected text format

P

Prosperina

It would be a lot of work to do it cell by cell.
I have a long range of cells that need just one word to be in bol
format.
:
 
R

Ryan Poth

Prosperina,

Here is a short VBA routine that I think will accomplish what you want.
Select the range of cells you want to be affected, then run the routine.

Sub MakeWordBold()
Dim c As Range, MyWord As String, SearchStart As Integer
MyWord = InputBox("String:", "Enter exact sting to make bold")
If MyWord = "" Then Exit Sub

For Each c In Selection
SearchStart = 1
Do While InStr(SearchStart, c.Value, MyWord, vbTextCompare) > 0
c.Characters(Start:=InStr(SearchStart, c.Value, MyWord,
vbTextCompare), Length:=Len(MyWord)).Font.FontStyle = "Bold"
SearchStart = InStr(SearchStart, c.Value, MyWord, vbTextCompare) +
Len(MyWord)
Loop
Next c
End Sub


This, of course, makes the assumption that you know how to insert a VBA
module into your spreadsheet, so I hope you do ;)

HTH,
Ryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top