Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Sub test()
- Dim LastRow As Long, i As Long
- 'Set you sheet
- With ThisWorkbook.Worksheets("Sheet1")
- LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
- 'Start from row 2
- For i = 2 To LastRow
- If Not IsEmpty(.Range("A" & i).Value) Then
- .Range("B" & i - 1).Value = .Range("B" & i).Value + .Range("B" & i - 1).Value
- Else
- .Range("B" & i + 1).Value = .Range("B" & i).Value
- End If
- Next i
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement