I hope someone can help me with this, it might not be that complicated. I have a code that looks for a value in a cell and then finds that value in a range, once the value is located it will place a value in another cell offset by 3 columns.
So for example: If "Dog" is in cell H10, then the code looks for "Dog" in column A, when it finds a cell that has Dog in it, it will place "Y" the same row but offset 3 columns (column D).
The code works PERFECT for what I need it to do with one exception... unfortunately if "Dog" appears in column A more than once, the code will only work for the first occurrence and not the second.
Does anyone know how to modify this code so it will continue until ALL occurrences of Dog in Column A have "Y" in column D on the same row?
Code:
Sub Mark() Sheets("Sheet1").Select
Dim LR As Long, i As Long
With Sheets("Sheet1")
LR = .Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With .Range("A" & i)
If .Value = Range("H10").Value Then
.Offset(0, 3).Select
Selection.Value = "Y"
Exit Sub
End If
End With
Next i
End With
End Sub
So for example: If "Dog" is in cell H10, then the code looks for "Dog" in column A, when it finds a cell that has Dog in it, it will place "Y" the same row but offset 3 columns (column D).
The code works PERFECT for what I need it to do with one exception... unfortunately if "Dog" appears in column A more than once, the code will only work for the first occurrence and not the second.
Does anyone know how to modify this code so it will continue until ALL occurrences of Dog in Column A have "Y" in column D on the same row?