Link to home
Create AccountLog in
Avatar of thutchinson
thutchinsonFlag for United States of America

asked on

Excel VBA to move a specific number of positions

I need a macro that will move down a worksheet and duplicate each record.
Then, I need to select every other cell in a column and move the value in the selected cell left one column.
Question:  How do I specify in VBA that I want to move, say, 2 cells down or 1 row down and then 2 rows left?

Thanks in advance for your help.
Avatar of Rgonzo1971
Rgonzo1971

Could you send a dummy?
EDIT
you could maybe do it like this
Sub macro()
lastRow = Range("A" & Cells.Rows.Count).End(xlUp).Row
For Idx = lastRow To 2 Step -1
    With Range("A" & Idx).EntireRow
        .Copy
        .Insert Shift:=xlDown
    End With
    Cells(Idx + 1, "C").Copy Destination:=Cells(Idx + 1, "D")
    Cells(Idx + 1, "C").ClearContents
Next
End Sub

Open in new window

EE20151224.xlsm
Avatar of thutchinson

ASKER

Hi Regonzo,

Thanks for your response.  Attached is a sample you requested.  I should have sent this before.  I hope I can understand your code because I'm trying to learn.  Thanks again.

Todd
ASKER CERTIFIED SOLUTION
Avatar of Rowan Scott
Rowan Scott
Flag of Australia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Sorry for the slow responses.  I'm totally under water at work. Thanks for your help.