View Single Post
  #2   Report Post  
Old April 16th 19, 07:27 PM posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
First recorded activity by ExcelBanter: Apr 2011
Posts: 3,696
Default Loop for text check in three colums and set a text code based on this in another column

Hi Johan,

Am Tue, 16 Apr 2019 10:41:42 -0700 (PDT) schrieb :

Loop in column A for all rows from second to last

If (li, co+13) contains text "AAA"
and (li, co+21) contains text "BBB"
and (li, co+22) contains text "CCC"
then set (li,co+25) the text "A"

If (li, co+13) contains text "DDD"
and (li, co+13) does not contains text "EEE"
and (li, co+22) contains text "FFF"
then set (li,co+25) the text "B"

end if

If (li, co+25) is empty
then set (li, co+25) the text "C"
end if

I don't know if I understood you correctly.
If the following code does not work for your problem explain a little

Sub Test()
Dim LRow As Long, i As Long
Dim varData As Variant, varOut() As Variant

With ActiveSheet
LRow = .Cells(.Rows.Count, "A").End(xlUp).Row
varData = .Range("A2:Y" & LRow)
ReDim varOut(UBound(varData) - 1)
For i = LBound(varData) To UBound(varData)
If varData(i, 14) & varData(i, 22) & varData(i, 23) = "AAABBBCCC" Then
varOut(i - 1) = "A"
ElseIf varData(i, 14) & varData(i, 23) = "DDDFFF" _
And varData(i, 22) < "EEE" Then
varOut(i - 1) = "B"
varOut(i - 1) = "C"
End If
.Range("Z2").Resize(UBound(varOut) + 1) =
End With
End Sub

Claus B.
Office 2016