VBA Copy range and paste as the values in a different workbook

GuyGadois

Active Member
Joined
Jan 12, 2009
Messages
342
Office Version
  1. 2019
Platform
  1. Windows
I am looking for a way to simplify something I do manually. I copy a range (which varies in length) and insert it in an existing workbook starting at A2, moving the existing data down. Here are the step I do manually
1. Highlight the range from E5 to G(to the end of the data)
2. Open the target workbook (the workbook varies)
3. Insert the copied range values and move the existing data (which is always starting at A2 and is three columns wide). The extra step is the data I am copying has to be pasted as values and I want to insert it and move existing data down.



I want to copy the data under the headers. In this case, is E5:G23 in the worksheet (called "Portfolios" or Sheet14) but the range varies in length but will always be three columns wide
DateSymbol Target Weight
01/15/2022AAPL0.0344
01/15/2022ACN0.0052
01/15/2022ADP0.0060
01/15/2022AMP0.0082
01/15/2022BX0.0068
01/15/2022C0.0042
01/15/2022CC0.0050
01/15/2022CMG0.0060
01/15/2022COST0.0046
01/15/2022CTLT0.0030
01/15/2022DHR0.0050
01/15/2022DUK0.0032
01/15/2022EA0.0024
01/15/2022EL0.0052
01/15/2022FB0.0068
01/15/2022HON0.0044
01/15/2022J0.0048
01/15/2022KO0.0038
01/15/2022LLY0.0066


I would like the VBA to prompt the user to pick a destination workbook which would open up a workbook like below (but it could have hundreds on line of data (this is a small sample of the top portion of the data). The data from the source workbook should be pasted (as values) under the headers while moving the data down.

99 Growth Y Charts DYNAMIC 01-15-22.xlsx
ABC
1610/16/2020aapl0.0082
1710/16/2020acn0.0044
1810/16/2020adp0.0058
1910/16/2020amp0.0074
2010/16/2020amt0.0038
2110/16/2020bx0.005
2210/16/2020c0.0058
2310/16/2020cmg0.0066
2410/16/2020cost0.0036
2510/16/2020ctlt0.0034
2610/16/2020dis0.007
2710/16/2020el0.0054
Sheet1


this is the result after pasting
99 Growth Y Charts DYNAMIC 01-15-22.xlsx
ABC
201/15/2022AAPL0.0344
301/15/2022ACN0.0052
401/15/2022ADP0.006
501/15/2022AMP0.0082
601/15/2022BX0.0068
701/15/2022C0.0042
801/15/2022CC0.005
901/15/2022CMG0.006
1001/15/2022COST0.0046
1101/15/2022CTLT0.003
1201/15/2022DHR0.005
1301/15/2022DUK0.0032
1401/15/2022EA0.0024
1501/15/2022EL0.0052
1601/15/2022FB0.0068
1701/15/2022HON0.0044
1801/15/2022J0.0048
1901/15/2022KO0.0038
2001/15/2022LLY0.0066
2110/16/2020aapl0.0082
2210/16/2020acn0.0044
2310/16/2020adp0.0058
2410/16/2020amp0.0074
2510/16/2020amt0.0038
2610/16/2020bx0.0050
2710/16/2020c0.0058
2810/16/2020cmg0.0066
2910/16/2020cost0.0036
3010/16/2020ctlt0.0034
3110/16/2020dis0.0070
3210/16/2020el0.0054
Sheet1


Is this possible to do this? Any help is greatly appreciated.

Cheers,

GG
 
Last edited:

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.

Forum statistics

Threads
1,214,874
Messages
6,122,036
Members
449,062
Latest member
mike575

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