Dynamic Named Range Based upon Column A

spydey

Active Member
Joined
Sep 19, 2017
Messages
314
Office Version
  1. 2013
Platform
  1. Windows
Maybe this is a simple thing and I am over complicating it.

I think that I have it solved but I just wanted to check to make sure, so any input you have is greatly appreciated!!

I need to create several dynamic named ranges, each for a different column. They are single column ranges, 1 dimensional.

The issue is that for all columns, except A, there are blanks in between the different data sets.

Example, column B might have data spanning from rows B1:B30, then B50:B150, then B300:B2000. In between each of those sets it is blank.

Column A has no blanks from the beginning of the data set to the end, so it could span for example A1:A2305. It is continuous.

All other columns will never have data past rows where A does not contain data. Whichever row A's data ends on, that is the last row of data for all columns.

I need to set a dynamic named range based upon the number of rows in column A, but for the other columns which have blanks in between their data sets, so that rows are in the named range, whether the row is blank or not for that particular column.

I was thinking something like this:

=D1:Index($D:$D,CountA($A:$A))

I would change the "D" column references to the correct column as needed. Column A reference would stay the same for all columns.

My hope is that this would give me a dynamic named range for the column in question (in the example it is "D") and would include all rows, as per the number of rows in column A which have data.

I was avoiding using Offset because of its volatility.

Do any of you have any suggestions, corrections to my formula, ideas, etc?

Thanks in advance!!

-Spydey
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi Spydey,

I think that approach makes sense. The only slight variation you might consider is to use another named range "LastRow", refers to =CountA($A:$A) and reference that for each column-specific name. Not a big difference, but it could eliminate the need to modify each column specific named range if you change the column that has no blanks or add blank rows above your dataset.
 
Last edited:
Upvote 0
if it suits, have VBA create the defined names. then they can be simple - without any formulas

such as on some event, like worksheet deactivate (if it suits)
say a bit like Jerry said,
LastRow = cells(rows.count,1).end(xlup).row
someArray = array("A", "D", "G", "M", "Q")
for i = lbound(someArray) to ubound(someArray)
range(someArray(i) & "1").resize(LastRow).name = "col" & someArray & "_name"
next i

that just to give the idea
 
Upvote 0
Hi Spydey,

I think that approach makes sense. The only slight variation you might consider is to use another named range "LastRow", refers to =CountA($A:$A) and reference that for each column-specific name. Not a big difference, but it could eliminate the need to modify each column specific named range if you change the column that has no blanks or add blank rows above your dataset.

That is a fantastic idea!! Have one named range for the Last Row and reference that named range in my formula instead of writing the ending of the formula 50 times!!

Great recommendation. Thanks Jerry!!

-Spydey
 
Upvote 0
if it suits, have VBA create the defined names. then they can be simple - without any formulas

such as on some event, like worksheet deactivate (if it suits)
say a bit like Jerry said,
LastRow = cells(rows.count,1).end(xlup).row
someArray = array("A", "D", "G", "M", "Q")
for i = lbound(someArray) to ubound(someArray)
range(someArray(i) & "1").resize(LastRow).name = "col" & someArray & "_name"
next i

that just to give the idea

Interesting ..... I hadn't thought about using VBA for this particular purpose but looking at it now, it might not be a bad idea. It would eliminate a number of complications that currently exist.

Thanks Fazza, I will have to investigate a bit more.

-Spydey
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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