Hello Experts,
I am a VBA beginner. I have been trying to write a code which checks for cell value in the last empty row. If the last cell is empty then the code should increment with the previous cell value. If cell A1 has value 10 then code should check if A2 is empty and then increment A1 value by 1 in A2 and move on to A3, A4 etc. Can any one help please?
I am a VBA beginner. I have been trying to write a code which checks for cell value in the last empty row. If the last cell is empty then the code should increment with the previous cell value. If cell A1 has value 10 then code should check if A2 is empty and then increment A1 value by 1 in A2 and move on to A3, A4 etc. Can any one help please?
Code:
sub test_1()
Dim LR As Long
Dim r As Range, cel As Range
LR = Range("A" & Rows.Count).End(xlUp).Row
Set r = Range("A" & LR)
For Each cel In r
If r.Value = "" Then
r.Value = 1
Else
r.Value = r.Value + 1
End If
Next cel
End Sub