VBA to copy 2 columns and paste multiple times into another sheet based on a cell value

nellyc

New Member
Joined
Mar 22, 2023
Messages
8
Office Version
  1. 2010
Platform
  1. Windows
Hi All

I am looking for some VBA to copy columns A & B in "Sheet2" then paste, including formulas to the last available column in sheet "Stock Sheet" multiple times based on a cell value in "Stock Sheet" Cell A4.

any suggestions would be greatly appreciated.

thx,
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try this code. Change range as required.
VBA Code:
Sub Macro1()
Dim T&
Sheets("Sheet2").Range("A1:B15").Copy
Sheets("Stock Sheet").Activate
For T = 1 To Sheets("Stock Sheet").Range("A4")
Range("A1").End(xlToRight).Offset(0, 1).Select
ActiveSheet.Paste
Next
End Sub
 
Upvote 0
Thank you, with a bit of adjustment it works well.

Now i need to work out how to keep the formula's in the correct place.
The Formula is - =IF($B8=$BA6,$J8,0), I can seem to lock the middle cell ref to the new columns no matter where the $ signs are placed, any suggestions?
The $BA6 Cell ref in the formula needs to be static on each cell in the inserted columns - so if i insert 3 sets of columns after column BA it need to move to BC, BD etc

Hope that makes sense :)
 
Upvote 0

Forum statistics

Threads
1,224,928
Messages
6,181,811
Members
453,067
Latest member
mdiz777

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