prometheus
04-21-2016, 12:48 PM
hi
wrote below code
overal structure is : test if a certain value exists in range AI ---- i wrote .range("ai:aw") because ("ai') doenst seem to work ? how do i correctly reference one column? .columns("ai") ?
so it should check if it finds the value in that specific column if not do A, else do B
somehow both A and B seperately work, but the combination doenst.. any tips?
edit, when i run the code it looks like it either executes A for the full list or B for the full list, while it should infact evaluate per line to do A or B...
If IsError(Application.Match(Cells(21 + i, 31), Sheets("data").Range("ai:aw"), 0)) Then
Do While Cells(21 + i, 31).Value <> ""
Cells(21 + i, 37).Value = Application.VLookup(Cells(21 + i, 31), Sheets("data").Range("ai:aw"), 11, False)
i = i + 1
Loop
Else
Do While Cells(21 + i, 31).Value <> ""
Cells(21 + i, 37).Value = Application.VLookup(Cells(21 + i, 31), Sheets("data").Range("aj:aw"), 12, False)
i = i + 1
Loop
End If
End Sub
wrote below code
overal structure is : test if a certain value exists in range AI ---- i wrote .range("ai:aw") because ("ai') doenst seem to work ? how do i correctly reference one column? .columns("ai") ?
so it should check if it finds the value in that specific column if not do A, else do B
somehow both A and B seperately work, but the combination doenst.. any tips?
edit, when i run the code it looks like it either executes A for the full list or B for the full list, while it should infact evaluate per line to do A or B...
If IsError(Application.Match(Cells(21 + i, 31), Sheets("data").Range("ai:aw"), 0)) Then
Do While Cells(21 + i, 31).Value <> ""
Cells(21 + i, 37).Value = Application.VLookup(Cells(21 + i, 31), Sheets("data").Range("ai:aw"), 11, False)
i = i + 1
Loop
Else
Do While Cells(21 + i, 31).Value <> ""
Cells(21 + i, 37).Value = Application.VLookup(Cells(21 + i, 31), Sheets("data").Range("aj:aw"), 12, False)
i = i + 1
Loop
End If
End Sub