VBA - creating table by referring to defined name range

Machds42

Board Regular
Joined
Apr 23, 2007
Messages
54
I am attempting to write a macro, that will find the pre-defined name of a range (eg; I have named a1:c5 "Table_1"), then paste all cells into a given range on a different sheet

Cheers Tim
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I should qualify by saying that the defined name range is in a cell

i.e. cell a10 will have the name "Table_1" in it, so i was planning on using the contents of the cell as the reference point to the desired table's name
 
Upvote 0
Turn on the macro recorder (Tools | Macro > Record new macro...), select and copy a range of cells, and paste wherever you want to paste them. Turn off the recorder and Excel should give you the necessary code to do what you want. You can then replace the range Excel uses with the name that is in Cell A10 of whichever sheet.

Once done you should also visit
Beyond the macro recorder
http://www.tushar-mehta.com/excel/vba/beyond_the_macro_recorder/index.htm
 
Upvote 0
I have tried this and cant get it to work

The name range can continually change depending on the users preference

For example, the file contains 100 different tables - Table_1 - Table_100

The user has a drop down where they can choose whichever table they wish - a formula is written which refers to this name, and gives you the defined name of the range for that table.

I then need to use this defined name to find the table in the file somewhere, and paste the range.
 
Upvote 0
So, what's the code you got through the macro recorder?
I have tried this and cant get it to work

The name range can continually change depending on the users preference

For example, the file contains 100 different tables - Table_1 - Table_100

The user has a drop down where they can choose whichever table they wish - a formula is written which refers to this name, and gives you the defined name of the range for that table.

I then need to use this defined name to find the table in the file somewhere, and paste the range.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

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