Can I use loops to enhance this code?

M

Max

Can I use loops to enhance this code?
Sheet24.Cells(5, 2).Copy Destination:=Sheet5.Cells(10, 3)
Sheet24.Cells(5, 3).Copy Destination:=Sheet5.Cells(10, 4)
Sheet24.Cells(5, 4).Copy Destination:=Sheet5.Cells(11, 3)
Sheet24.Cells(5, 5).Copy Destination:=Sheet5.Cells(11, 4)
Sheet24.Cells(5, 6).Copy Destination:=Sheet5.Cells(12, 3)
Sheet24.Cells(5, 7).Copy Destination:=Sheet5.Cells(12, 4)
Sheet24.Cells(5, 8).Copy Destination:=Sheet5.Cells(13, 3)
Sheet24.Cells(5, 9).Copy Destination:=Sheet5.Cells(13, 4)
Sheet24.Cells(5, 10).Copy Destination:=Sheet5.Cells(14, 3)
Sheet24.Cells(5, 11).Copy Destination:=Sheet5.Cells(14, 4)
Sheet24.Cells(5, 12).Copy Destination:=Sheet5.Cells(15, 3)
Sheet24.Cells(5, 13).Copy Destination:=Sheet5.Cells(15, 4)
Sheet24.Cells(5, 14).Copy Destination:=Sheet5.Cells(16, 3)
Sheet24.Cells(5, 15).Copy Destination:=Sheet5.Cells(16, 4)
 
J

Javed

Sub LoopEffect()

Dim Sheet24 As Worksheet, Sheet5 As Worksheet
Dim i As Long, j As Long

Set Sheet24 = Worksheets(2)
Set Sheet5 = Worksheets(3)

For i = 2 To 15
j = i Mod 2
Sheet5.Cells((9 + (i - j) / 2), j + 3) = Sheet24.Cells(5,
i).Value
Next i

End Sub

Pls check.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top