0
votes

I have been working on a piece of VBA code for a while now but with no joy. I am at the beginnings of understanding code, the next step is writing it. I am thinking this may involve a for next loop or a do until loop.
This is what I am trying to achieve

Range A1 to A15 with letters

Range D1 to D15 empty

Copy the value in Range A1 to B1, then copy the value in Range C1 to D1.

Then copy the value in Range A2 to B1 and then copy the value in Range C1 to D2.

Repeat these steps until Range A15 has been copied and the result into D15.

Thank you for reading.

1
Did you mean A2 to B2? I don't know why you'd want to write over B1. Typo? - peege

1 Answers

1
votes

This should do what you are asking.

Private Sub simpleCopyLoop()
Dim row As Long

For row = 1 to 15

    Sheets("Sheet1").Cells(row, "B").Value = Sheets("Sheet1").Cells(row, "A").Value   
    Sheets("Sheet1").Cells(row, "D").Value = Sheets("Sheet1").Cells(row, "C").Value 

Next row

End Sub