Reputation: 1
Please not that this is one of the first VBA code I have written. What I wrote was a mixture of a loop and If function. The code was supposed to go through column("AC"), if it finds an empty cell. It looks at the same row but in column D. Column D would have 350 possible values. If the value of Column D is "one of 350 possible values" then give "EU" ElseIf... this continues for all 350
Dim i As Long
i = 1
Do While Cells(i, "AC").Value <> ""
If Cells(i, "D").Value = "OPP-1305-9066" Then
Cells(i, "AC").Value = EU
ElseIf Cells(i, "D").Value = "OPP-1305-0773" Then
Cells(i, "AC").Value = EU
ElseIf Cells(i, "D").Value = "another one of 350" Then
Cells(i, "AC").Value = EU
End If
i = i + 1
Loop
Upvotes: 0
Views: 31
Reputation: 954
Not sure what your questions is, but unless EU is a variable, you are missing brackets. Also you only loop while column AC is not empty, so if AC2 is empty but there's more data after cell AC4 you're not checking it.
And most importantly, 350 elseif statements, wow! :) You will benefit from learning about arrays/collections.
Upvotes: 1