Good morning good people.
I find that what I need MS find is not sufficient for my needs. I want to find a number of text in a Excel cell and make the cell bold.
I can do this with the first one, but I am having trouble do this for each one in the spreadsheet. With the following code I can use it to find and replace, but I want the user to have control and search for the first occurrance (and bold it) and then either click the find button again or another command button (find next) to go to the second occurrance (3rd, 4th, 5th, etc.).
Any suggestions? DAVE
Private Sub cmdFind_Click()
Dim Counter As Integer
Private Sub cmdFind_Click()
With Worksheets(1).Range("A1
2000")
'Find
Set c = .Find(txtFind.Text, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
'Replace
Do
c.Rows.Select
Selection.Font.Bold = True
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
Else
MsgBox "Sorry " & txtFind.Text & " was not found."
End If
End With
End Sub
I find that what I need MS find is not sufficient for my needs. I want to find a number of text in a Excel cell and make the cell bold.
I can do this with the first one, but I am having trouble do this for each one in the spreadsheet. With the following code I can use it to find and replace, but I want the user to have control and search for the first occurrance (and bold it) and then either click the find button again or another command button (find next) to go to the second occurrance (3rd, 4th, 5th, etc.).
Any suggestions? DAVE
Private Sub cmdFind_Click()
Dim Counter As Integer
Private Sub cmdFind_Click()
With Worksheets(1).Range("A1
'Find
Set c = .Find(txtFind.Text, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
'Replace
Do
c.Rows.Select
Selection.Font.Bold = True
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
Else
MsgBox "Sorry " & txtFind.Text & " was not found."
End If
End With
End Sub