I have an worksheet that has 3 columns A-C of text.
I want to write a VBA script to loop through each row and if (in each row) col a = (text 1 or text 2) AND col b = (Text5 or text 6 or text 7 or text 8) AND col c = (Text20 or Text 22) put a yes in column D
I was thinking of putting my text values to search for in multiple arrays:
Dim Search1 As Variant
Dim Search2 as Variant
Dim Search3 as Variant
Search1 = Array("Cat", "Dog")
Search2 = Array("Red", "Brown", "Blue")
Search2 = Array("House", "Condo")
Then do a loop through the rows:
Dim i As Long
For i = 1 To rg.Rows.Count
Where I'm stuck is the search logic:
Application.CountIFs(Cells(i,1),Search1, Cells(i,2), Search2, Cells(i,3), Search4)) > 0 then
sh.Cells(i, "F").Value = "yes"
i = i + 1
End if
Next i
So something like:
A B C D
Dog Brown House Y A=(Dog or Cat) AND B=(Brown or Blue or Red) AND C =( House or Condo)
Bird Blue House
Cat Brown Condo Y
Cat Pink Condo
Cat Blue House Y
Horse Red Condo
Cat Green House
Dog Pink Condo
Horse Blue House
I hope this make sense...I'm really looking for how to do the countIF(Range, Array, Range,Array, Rang, Array) for each row.
Thank you!