VBA, Copy Cell formula to a defined Name

Luluwai

New Member
Joined
Aug 29, 2008
Messages
9
We have a cell A1 with the formula (say) "=[Pricelist2019v2.xls]Company!$A$1:$L$22000"

We want to use VBA to copy this to a Defined Name, (say) "RangeA".

We have tried may possible ways of doing this without success.
So suggestions appreciated as to how this may be accomplished!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try

Code:
Sub test2()
    Range("A1").Copy Range("RangeA")
End Sub
 
Upvote 0
Many thanks, and I owe you and apology, in that I did not define the requirement exactly. I want to copy the actual formula in A1 into the Name "Range" as I need to use the name "Range" (and variation on this name) in a number of places (like some 20,000 places) in the workbook as one cell pivot tables.

Comments appreciated.
 
Upvote 0
I think I did not understand, but try this

Code:
Sub Macro2()
    ActiveWorkbook.Names("RangeA").RefersToR1C1 = Range("A1").Formula
End Sub
 
Upvote 0
Hi, could not get it to work. In essence the Name "RangeA" has to contain the formula "=[Pricelist2019v2.xls]Company!$A$1:$L$22000" which will be used in a cell (88,000 to be exact) {=INDEX(rangeA,MATCH($C73&E$68,rangeA1&rangeA2,0),5)} etc.. And it takes some 5 hours to make the calculations.

I'm trying to build a foolproof workbook which, whenever we receive new spreadsheet, can be integrated into our normal 'working' spreadsheet by inexperienced users of same.

 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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