Hello people,
I have this code that loops through the cells of a single row. For some reason, the "Exit for" is not working making vba copy the string to the 33 cells. Ideally, this code should check the looped cell if it is equal to the string. If not, just paste it on the next available cell in the row. the string value changes through another loop in my full code.
Here is the code:
Thanks for the help
I have this code that loops through the cells of a single row. For some reason, the "Exit for" is not working making vba copy the string to the 33 cells. Ideally, this code should check the looped cell if it is equal to the string. If not, just paste it on the next available cell in the row. the string value changes through another loop in my full code.
Here is the code:
Code:
Sub check()
'
Dim uniquevendor As String
uniquevendor = "shakeeb92"
Set Krange = Sheets("sheet3").Range("B1:B33") '33 is a random number just to make sure that it checks all the cells in the row
For Each Kcell In Krange
If Kcell.Value = uniquevendor Then
Exit For
Else
If Range("b1").Value = "" Then
Range("b1").Value = uniquevendor
Else
Sheets("sheet3").Range("A1").End(xlToRight).Select
ActiveCell.Offset(0, 1) = uniquevendor
End If
End If
Next Kcell
'
End Sub
Thanks for the help