I want to query based on the values in different cells in an Excel sheet and color the rows where these values are located at the same time. The current code just colors a single line and the loop stops. Can you help me, where should I fix the code to apply the loop to the entire table?
`Sub SearchAndHighlightIE()
Dim ws As Worksheet
Dim searchRange As Range
Dim foundCell As Range
Dim firstAddress As String
Dim searchTerm As String
' Kullanicidan arama terimi al
'searchTerm = InputBox("Aranacak kelimeyi giriniz:", "Arama Terimi")
' Eger kullanici bir sey girmeden iptal ederse, makroyu sonlandir
'If searchTerm = "" Then Exit Sub
' Aktif çalisma sayfasini ayarla
Set ws = ActiveSheet
' Arama yapilacak alan (tüm sayfa varsayilan olarak)
Set searchRange = ws.UsedRange
' Arama terimiyle ilk bulusu bul
Set foundCell0 = searchRange.Find(What:="Ýmal Edilen", LookIn:=xlValues, LookAt:=xlPart)
Set foundCell1 = searchRange.Find(What:="SLDPRT", LookIn:=xlValues, LookAt:=xlPart)
' Eger bir sonuç bulunursa
If Not foundCell0 Is Nothing Then
firstAddress0 = foundCell0.Address
If Not foundCell1 Is Nothing Then
firstAddress1 = foundCell1.Address
Do
' Hücreyi sariyla isaretle
foundCell0.EntireRow.Interior.Color = RGB(255, 255, 153)
' Sonraki bulusu ara
Set foundCell0 = searchRange.FindNext(foundCell0)
Loop While Not foundCell0 Is Nothing And foundCell0.Address <> firstAddress0
Else
MsgBox "Aranan terim bulunamadi."
End If
End If
End Sub`
only one row highlighted in an excel sheet
Gürkan Durukal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.