VBA to Create Named Ranges Based on Cell Contents

Texas Longhorn

Active Member
Joined
Sep 30, 2003
Messages
493
Hi all,

I have a worksheet with several dozen columns of data. The first column contains dates, and I have a dynamically named range for this called DataDates which is defined as =OFFSET(Summary!$A$13,0,0,COUNT(Summary!$A:$A),1). I have manually created a few more named ranges in the Sheet; an example is FinMetric1 which is defined as =OFFSET(DataDates,0,COLUMNS(Summary!$A$12:$C$12)-1).

Rather than continue to manually name the remaining ~40 ranges, I would like to use VBA to automate the process. My plan (which I am failing to execute) is as follows: For each column for which I'd like to have a named range, I would type a "Name" field in row 9 and a "Refers To" formula in row 10 above the relevant data. For example, column X contains data that I want to name "FinMetric2." So in X9 I would have FinMetric2 and in X10 I would have OFFSET(DataDates,0,COLUMNS(Summary!$A$12:$X$12)-1). Column AA contains data I want to name "FinMetric3" so AA9 would contain FinMetric3 and AA10 would contain OFFSET(DataDates,0,COLUMNS(Summary!$A$12:$AA$12)-1). Etcetera.

My problem is that I do not know how to have VBA reference the contents in rows 9 and 10 when defining the names. Can anyone point me in the right direction?

Many thanks,

Bill
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,214,827
Messages
6,121,816
Members
449,049
Latest member
cybersurfer5000

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