Title explains it. This code finds all values of X , at beginning, in the middel or at the end of cell text down a column and displays results in RESULT sheet.
Everybody is familiar with this standard FIND method code:
And it works very well - faster than Autofilter. (searching in column with 31,000 rows of data)
If the value of x = "embrace", the code above gives 14 results and displays the entire cell text
as below image. Note that the DESIRED RESULT image has the value of X in red and bolded. But that
is in the sheet's cell value - NOT in the userform. The yellow highlighted value in the form is what
I want to "appear" ref and bolded.
How would I tell excel: "OK, now that the value of x is found in all rows, just display x in
red and bolded in the userform - not the cell text. (The userform does not display it in red and bolded
even if the underlying value in the sheet cell is colored red and bolded. )
Thanks for anyone's help. Apologies for long explanation. Wanted to show all that I needed to have done.
cr
Everybody is familiar with this standard FIND method code:
Code:
Private Sub CommandButton1_Click()
Dim X As String
Dim c As Range
Dim rw As Long
Dim firstaddress As Variant
Dim rowno As Integer
[B]X = Me.TextBox1.Value --->value to FIND and (1) color Font red and (2) change to Bold[/B]
With Worksheets("KJV").Range("A2:B31103")
Set c = .Find(X, LookIn:=xlValues, LookAt:=xlPart)
If Not c Is Nothing Then
rw = 2
firstaddress = c.Address
Do
Worksheets("KJV").Select
c.Select
[B]'Selection.Font.Color = RGB(255, 0, 0)<---maybe code should go here. This just colors the entire text found in the cell red – NOT just the value of X (which is what I want)[/B]
MsgBox "Value found in cell " & c.Address
Destination:=Sheets("RESULT").Range("A" & rw)
Range(Cells(c.Row, 1), Cells(c.Row, 2)).Copy Destination:=Sheets("RESULT").Range("A" & rw)
rw = rw + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End With
rowno = Sheets("RESULT").Range("B2").End(xlDown).Row
MsgBox rowno
Sheets("RESULT").Range("B1").Value = rowno
Me.TextBox2.Value = Sheets("RESULT").Range("B1").Value
And it works very well - faster than Autofilter. (searching in column with 31,000 rows of data)
If the value of x = "embrace", the code above gives 14 results and displays the entire cell text
as below image. Note that the DESIRED RESULT image has the value of X in red and bolded. But that
is in the sheet's cell value - NOT in the userform. The yellow highlighted value in the form is what
I want to "appear" ref and bolded.
How would I tell excel: "OK, now that the value of x is found in all rows, just display x in
red and bolded in the userform - not the cell text. (The userform does not display it in red and bolded
even if the underlying value in the sheet cell is colored red and bolded. )
Thanks for anyone's help. Apologies for long explanation. Wanted to show all that I needed to have done.
cr