VBA Copying Formulas

AD_Taylor

Well-known Member
Joined
May 19, 2011
Messages
687
Lets say in A1 I have a formula that has been array entered (Ctrl + Shift + Enter).
I want to copy this formula to Cell B1 but update the cell references etc. and to do this copy within VBA code.

Can I just use something like:

Code:
Range("B1").Formula = Range("A1").Formula

?

As I'm assuming that would copy the formula but not update the references?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
How about

Code:
Range("A1").Copy = Range("B1")
 
Upvote 0
Sorry, spurious equals sign:

Code:
Range("A1").Copy Range("B1")
 
Upvote 0
I believe this will do what you want as well.

Code:
Range("B1").FormulaArray = Range("A1").FormulaR1C1
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,823
Members
452,946
Latest member
JoseDavid

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