Webbers
07-30-2019, 09:11 AM
Hi all!
I found a great and functional code here, which was written by Yongle. I modified the code, however I don't want to be forced to manually hardcode all the variables that could appear. There are numbers, rather than specific text, and they are all in the same format with a parenthesis before and after the number, such as (1), (2), (3), and so forth. I would like all numbers (and the parenthesizes) to be bold and green (color index 10).
Sub Find_and_Bold()
Dim rCell As Range, sToFind As String, iSeek As Long
Dim Text(1 To 5) As String
Dim i As Integer
Text(1) = "(1)"
Text(2) = "(2)"
Text(3) = "(3)"
Text(4) = "(4)"
Text(5) = "(5)"
For i = LBound(Text) To UBound(Text)
For Each rCell In Range("G1:G50")
sToFind = Text(i)
iSeek = InStr(1, rCell.Value, sToFind)
Do While iSeek > 0
rCell.Characters(iSeek, Len(sToFind)).Font.Bold = True
iSeek = InStr(iSeek + 1, rCell.Value, sToFind)
Loop
Next rCell
Next i
End Sub
I found a great and functional code here, which was written by Yongle. I modified the code, however I don't want to be forced to manually hardcode all the variables that could appear. There are numbers, rather than specific text, and they are all in the same format with a parenthesis before and after the number, such as (1), (2), (3), and so forth. I would like all numbers (and the parenthesizes) to be bold and green (color index 10).
Sub Find_and_Bold()
Dim rCell As Range, sToFind As String, iSeek As Long
Dim Text(1 To 5) As String
Dim i As Integer
Text(1) = "(1)"
Text(2) = "(2)"
Text(3) = "(3)"
Text(4) = "(4)"
Text(5) = "(5)"
For i = LBound(Text) To UBound(Text)
For Each rCell In Range("G1:G50")
sToFind = Text(i)
iSeek = InStr(1, rCell.Value, sToFind)
Do While iSeek > 0
rCell.Characters(iSeek, Len(sToFind)).Font.Bold = True
iSeek = InStr(iSeek + 1, rCell.Value, sToFind)
Loop
Next rCell
Next i
End Sub