I am being an idiot and cannot for the life of me work out this simple VBA!!
I have a list of data starting from cell D16. If the value of cell D16 is zero, then I want E16 value to equal F16 value. Then I am trying to loop this in for every subsequent cell in D.
Below was my attempt and nothing happens...I know I'm being stupid here and missing something obvious, but just can't think!!
I have a list of data starting from cell D16. If the value of cell D16 is zero, then I want E16 value to equal F16 value. Then I am trying to loop this in for every subsequent cell in D.
Below was my attempt and nothing happens...I know I'm being stupid here and missing something obvious, but just can't think!!
VBA Code:
Sub test()
Dim lrow As Long, cell As Range
lrow = Range("D16").End(xlUp).Row
For Each cell In Range("D16:D" & lrow)
If cell.Value = 0 Then
cell.Offset(0, 1) = cell.Offset(0, 2).Value
End If
Next cell
End Sub