VBA to copy, paste, update value and loop

mena139

New Member
Joined
Dec 2, 2016
Messages
14
Hello I am fairly new to VBA and have been playing around with a few different things for the last few days while tryng to accomplish the following:

I would like to:
1) copy from cell b3:b6
2) paste it in sheet2 in cell a5
3) (back on sheet1) copy cell D3
4) paste on sheet2 in cell A3
5) (back on sheet1) add 1 to the value in cell a1
6) repeat step 1
7) repeat step 2 but move over one column
8) repeat step 3
9) repeat step 4 but move over one column
10) repeat step 5
11) loop through this 200X

any tips / suggestions would be greatly appreciated
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
hi

when you say repeat step 2 but move over one column, do youmean for the copy event or the paste event or both.

Dave
 
Upvote 0
Here:
Code:
Sub LoopCopy()
Dim i As Long
Application.ScreenUpdating = False
With Sheet1
    For i = 1 To 200
        .Range("B3:B6").Copy
        Sheet2.Cells(5, i).PasteSpecial xlPasteValues
        .Range("D3").Copy
        Sheet2.Cells(3, i).PasteSpecial xlPasteValues
        .Range("A1").Value = .Range("A1").Value + 1
    Next i
End With
End Sub
 
Upvote 0
test this on a copy of your workbook

Code:
Sub copystuff()
d = 0
Do Until d = 20

    Worksheets("Sheet1").Range("B3:B6").Copy
    Worksheets("sheet2").Range("a5").Offset(, d).PasteSpecial
    
    Worksheets("Sheet1").Range("D3").Copy
    Worksheets("sheet2").Range("a3").Offset(, d).PasteSpecial
    
    Worksheets("sheet1").Range("a1") = Worksheets("sheet1").Range("a1") + 1

d = d + 1

Loop

End Sub

dave
 
Upvote 0
sorry

Do Until d = 20

should be

Do Until d = 200

dave
 
Upvote 0

Forum statistics

Threads
1,214,573
Messages
6,120,318
Members
448,956
Latest member
Adamsxl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top