Hi. I am beginner to excel vba. I would like to ask simple question that I've been stuck for few days.
So far, I have two columns, for example column L and M.
I have to loop all column L and find the blank cell. If there are a blank cell, then, it will copy next value in column M.
Roughly, the column is like this,
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Column L[/TD]
[TD]Column M[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]
so supposedly second row of column L will be 4. The flow will be until end of the lastrow.
So far, my code is like this,
Thanks in advance
So far, I have two columns, for example column L and M.
I have to loop all column L and find the blank cell. If there are a blank cell, then, it will copy next value in column M.
Roughly, the column is like this,
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Column L[/TD]
[TD]Column M[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]
so supposedly second row of column L will be 4. The flow will be until end of the lastrow.
So far, my code is like this,
Code:
Dim c As Range Dim searchrange As Range
Dim i As Long
Set searchrange = Range("L2", Cells(Rows.Count, 1).End(xlUp))
For i = searchrange.Cells.Count To 1 Step -1
Set c = searchrange.Cells(i)
If c.Value = "" Then
'c.Value.Copy Range("M2")
c.Value.Copy Destination:=Range("M")
End If
Next i
Thanks in advance