Dynamic Named Range Based upon Column A

spydey

Active Member
Joined
Sep 19, 2017
Messages
306
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
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Jerry Sullivan

MrExcel MVP
Joined
Mar 18, 2010
Messages
8,787
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:

Fazza

MrExcel MVP
Joined
May 17, 2006
Messages
9,368
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
 

spydey

Active Member
Joined
Sep 19, 2017
Messages
306
Office Version
  1. 2013
Platform
  1. Windows
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
 

spydey

Active Member
Joined
Sep 19, 2017
Messages
306
Office Version
  1. 2013
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,393
Messages
5,528,466
Members
409,818
Latest member
JiNXX9500

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top