My current code loops through range A62:A5000 (fixed / static range), and searches for word "PETER", wherever it find, it marks the text "PETER" Bold.
Dim xFind As String
Dim xCell, xTxtRg, xRg As Range
Dim xCount As Long
Dim xLen, xStart As Integer
On Error Resume Next
Set xRg = Activesheet.Range("A62:A5000")
'On Error Resume Next
Set xTxtRg = Application.Intersect(xRg.SpecialCells(xlCellTypeConstants, xlTextValues), xRg)
If xTxtRg Is Nothing Then
Exit Sub
End If
'where specific text found
xFind = "PETER"
xLen = Len(xFind)
For Each xCell In xTxtRg
xStart = InStr(xCell.Value, xFind)
Do While xStart > 0
xCell.Characters(xStart, xLen).Font.Bold = True
xCount = xCount + 1
xStart = InStr(xStart + xLen, xCell.Value, xFind)
Loop
Next
What I am now looking is to change the variable content, currently
to something like XFind = PETER SPACE and if this pattern with prefix PETER is found, to format only this portion of PETER + Pattern as bold within entire
Illustrations
PETER 4.3x ' no action PETER and anything >=5 with suffix .0x be marked as bold
PETER 5.2x ' since it is PETER blank space >=5, then entire PETER 5.2x portion be marked bold
PETER 305.2x ' since it is PETER blank space >=5, then entire PETER 305.2x portion be marked bold
PETER 2.2x ' since it is PETER blank space <5, then entire PETER 2.2x portion not be formatted
Content of any cell within Range A62:A5000 would have multiple lines (smaple workbook attached), but idea is to find where PETER + >= 5.0x is found and same (selected text in defined pattern) be formatted as bold
Without running the above code given in sample workbook, I have manually highlighted to illustrate what objective I want to achieve.
Sample Data starts from row cell A129
Bookmarks