vbalearner9999
vbalearner9999

Reputation: 5

VBA copy row values one row up

I have a filtered spreadsheet with alternating rows as follows: - a value in col A in one row - next row has values in col C and E Using VBA, how do I copy paste the values in col C and E up one row for the entire used range of the sheet?

enter image description here

I want the numbers to be moved up one row to be in the same row as the letters.

Upvotes: 0

Views: 193

Answers (1)

Vlad
Vlad

Reputation: 560

You should try this:

Sub MoveValues()    
    With ActiveSheet
        For Each Row In .Rows
            If Row.Cells(3) <> 0 Then
                Range(Cells(Row.Row, 3), Cells(Row.Row, 5)).Cut Destination:=Range(Cells(Row.Row - 1, 3), Cells(Row.Row - 1, 5))
            End If
        Next Row
    End With
End Sub

Upvotes: 0

Related Questions