Reputation: 3
I want to loop through a column and modify the adjacent column if a certain value is found.
I have it semi-working. It only modifies one value rather than all instances.
Sub PopulateField()
For i = 2 To Rows.Count
If Cells(i, 2).Value = "25 December 2018" Then
Cells(i, 3).Value = "Holiday"
Exit For
End If
Next i
End Sub
I would like it to be:
25 December 2018 Holiday
25 December 2018 Holiday
25 December 2018 Holiday
25 December 2018 Holiday
25 December 2018 Holiday
But currently it's only:
25 December 2018 Holiday
25 December 2018
25 December 2018
25 December 2018
25 December 2018
It doesn't seem to be iterating over all values.
Upvotes: 0
Views: 62
Reputation: 50008
You're exiting the loop after the first instance of 25 December 2018
.
Get rid of the Exit For
to continue iterating.
Upvotes: 3