Variable Variable Names

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,691
Office Version
  1. 365
Platform
  1. Windows
Is there a way to define a local variable (sheet1!name1) such that if I make a copy of the cells that contain both the variable and all references to it, that they will all be changed to a new name (sheet1!name2)?

I have a worksheet that contains a small variable-size table for calculating sums and averages for some experimental data. The table has about 10 columns and between 2 and 10 rows, depending on the number of readings. I have several local variables defined to make the formulas more readable such as "TimeTot", "TimeAve", "WtTotal", & "WtAve".

From time to time, I get new data. Up to now, whenever I received new data, I would replace the old data, which involved adding or deleting rows.

All that is working fine.

Now, when I get new data, I'd like to make a copy of the previous table and put the new data there so I have both the old and new data to look at. The problem is that the references in the new table point to the data in the old table. The cells in the new table that had local names in the old table have no names at all.

Is there any way to set up the table so that the variables automagically get a new unique name and all references get updated?

The only solution I have been able to come up with is to change the variable names in the table to add an index number ("TimeTot1", "TimeAve1", "WtTotal1", & "WtAve1"). Then when I copy the table, I first define new variable names with the next index number ("TimeTot2", "TimeAve2", "WtTotal2", & "WtAve2") then use Replace to change the references.

This works, but it's tedious and error-prone.

Is there a better way?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,603
Messages
6,179,855
Members
452,948
Latest member
UsmanAli786

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