I have a textbox on a userform which a macro populates a text string from another data source.
I want the user to be able to search in that textbox for a phrase of their choice. I'm fine with either centering the scroll on the text or bolding/underlining the specific phrases, but am struggling to do it.
This code supposedly works in worksheets, but how can I modify it to work in a userform textbox?
I want the user to be able to search in that textbox for a phrase of their choice. I'm fine with either centering the scroll on the text or bolding/underlining the specific phrases, but am struggling to do it.
This code supposedly works in worksheets, but how can I modify it to work in a userform textbox?
VBA Code:
Dim shp As Shape
Dim sFind As String
Dim sTemp As String
Dim iPos As Integer
Dim Response
sFind = InputBox("Search for?")
If Trim(sFind) = "" Then
MsgBox "Nothing entered"
Exit Sub
End If
sFind = LCase(sFind)
For Each shp In ActiveSheet.Shapes
sTemp = LCase(shp.TextFrame2.TextRange.Characters.Text)
iPos = InStr(sTemp, sFind)
If iPos > 0 Then
With shp.TextFrame2.TextRange.Characters(Start:=iPos, _
Length:=Len(sFind)).Font
.UnderlineStyle = msoUnderlineHeavyLine
.Bold = True
End With
End If
Next
MsgBox "Finished"