2

Need Help on Named Ranges in Formulas:

I have a second workbook ('TEST.xlsx') as the destination, referencing worksheet-scoped named ranges (in 12 columns X 75 rows) in the source workbook ('FLOW.xlsx'). I want to create a formula that will match a look-up value (a date entered into cell C3 in TEST that will return the matching named range IF there are 2 or more blank cells in that matched named range/column and the remaining named ranges/columns in that set of 12 columns with 2+ blank cells. The 12 separate columns in the source workbook ('FLOW') are named by month, year and location (ex., "jan_2019_class.1","feb_2019_class.1", etc.), the worksheet columns being C, H, M, R, W, AB, AG, AL, AQ, AV, BA, and BF. The rows are 80-155. I've only been able to make a simple working COUNTBLANK formula in my TEST workbook, ex.:

=COUNTBLANK('[FLOW.xlsx]Class_1-Chart'!jan_2019_class.1)

But NOT for successive columns (with different named ranges and the columns are non-sequential); and I can't figure out the functioning formula to combine with this to get the count AND data returned by criteria as described above. Please, no VBA/macros.

Thank you in advance for the help!

'TEST.xlsx' Screen Shot-RVSD

FLOW.xlsx- sample screenshot

johnp_c
  • 21
  • 3
  • Thanks for the reply, Terry W! – johnp_c Oct 03 '19 at 17:00
  • Terry W: The desired outcome is: Enter a desired start date (format: jan_2020_class.1) in cell C3 in TEST that will reference (or match) that class' worksheet in the source workbook FLOW and determine in that same year if: a) there are 2 or more blank cells in any of the 12 non-sequential columns, AND b) 2 or more blanks for 2 or more COLUMNS (months); then return the named range for the first of such columns in TEST's cell C6:C11. The goal: Find an opening for a starting student by entering a desired start month & year in TEST and identifying the named range by criteria in FLOW. Thanks!! – johnp_c Oct 03 '19 at 20:17
  • Terry W: I've also revised the TEST sheet image and added a sample shot of the FLOW sheet (Class 1 only) in original post above. Thanks! – johnp_c Oct 03 '19 at 20:25

1 Answers1

0

There are many approaches but I personally prefer the use of helper rows/columns/cells and named ranges.

In my demonstration I used two class attendant schedule in two different year from January to June as shown below (they are sitting in Column C to M in my example):

example

As shown above, I have added two helper rows on top of each schedule. The first helper row is used to find out if there is 2 or more vacancies in each month, if so returns TRUE. I have given the name check.2019.class.1 and check.2021.class.5 for each of them.

The second helper row is simply showing the range name of each month such as jan_2019_class.1, feb_2019_class.2 etc. I have given the name NameRng.2019.class.1 and NameRng.2021.class.5 for each of them.

On the TEST sheet I have the following set up:

TEST

where the look up value in cell C3 is actually returned by a formula so it can be "dynamically" changed by the user. Please note in the following formula I used a name ClassNo which is essentially the value from cell B3.

=B2&"_"&B1&"_class."&ClassNo

I have also named cell C3 as Start_MthYrClass which will be used in my following formula.

The formula for looking up the first available month in 2019 if the start month is jan_2019_class.1 is:

=INDEX(NameRng.2019.class.1,MATCH(1,(TRANSPOSE(ROW($1:$11))>=MATCH(Start_MthYrClass,NameRng.2019.class.1,0))*Check.2019.class.1,0))

Please note it is an array formula so you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar otherwise they will not function correctly.

demo1

The logic is to first "filter" the range NameRng.2019.class.1 using this formula =TRANSPOSE(ROW($1:$11))>=MATCH(Start_MthYrClass,NameRng.2019.class.1,0), in which ROW($1:$11) represents {1;2;3;4;5;6;7;8;9;10;11} and TRANSPOSE will turn it into {1,2,3,4,5,6,7,8,9,10,11}. This range of numbers represents the column index in that specific range which is Column C to M (in your case it would be ROW($1:$56) as your data is in Column C to BF). Then I use MATCH to return the start column index of the look up month jan_2019_class.1, and it should return 1 as this month starts in the 1st place/column in the range NameRng.2019.class.1. So this is what I am actually comparing: {1,2,3,4,5,6,7,8,9,10,11}>=1, and it will return {TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE}.

Then I multiply the above result with range Check.2019.class.1 which is essentially {FALSE,0,FALSE,0,TRUE,0,FALSE,0,TRUE,0,TRUE}. Then I will get {0,0,0,0,1,0,0,0,1,0,1}. FYI in Excel TRUE=1 and FALSE=0, so TRUE x FALSE = 0 while TRUE x TRUE = 1.

Lastly, I use MATCH to find out the position of the first 1 in the above result which is the 5th place/column, and then use INDEX to return the corresponding value from range NameRng.2019.class.1 which is mar_2019_class.1.

Here is a more universal formula which allows you enter it in the first cell C6 and drag it down to apply across board, if you have given names to the relevant cells and ranges in the same way as what I have demonstrated.

=IFERROR(INDEX(INDIRECT("NameRng."&B6&".class."&ClassNo),MATCH(1,(TRANSPOSE(ROW($1:$11))>=MATCH(Start_MthYrClass,INDIRECT("NameRng."&B6&".class."&ClassNo),0))*INDIRECT("Check."&B6&".class."&ClassNo),0)),"")

It is also an array formula so you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar.

It is essentially the same formula as the first one but I have added IFERROR to return a blank cell if there is no match, and I used INDIRECT to refer to the named ranges dynamically based on the year and class number chosen.

Now, if I change the look up criteria to mar_2021_class.5, here is an updated result:

demo2

Let me know if you have any questions. Cheers :)

Community
  • 1
  • 1
Terry W
  • 3,199
  • 2
  • 8
  • 24