Formula works in spreadsheet but not in Name Manager

sparky2205

Active Member
Joined
Feb 6, 2013
Messages
480
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi folks,
this formula ...
Excel Formula:
="Sheet1!$B$2:" & "Sheet1!" & ADDRESS(2,COLUMNS(DataTable),1)
... works in a spreadsheet but doesn't work when I use it in Name Manager as the range for a Named Range.

If more detail is required I can provide it but I'm assuming this is either not possible or I have made a mistake in my syntax.

I'm trying to create a dynamic Named Range based on rows that will change as columns are added to a table.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
It is a table. I use this a lot to dynamically set named ranges when extra rows are added.
However, it doesn't appear to behave the same when adding columns.
 
Upvote 0
I use this a lot to dynamically set named ranges when extra rows are added.
Does "this" mean an Excel table? Named ranges are not necessary when using Tables as they also are named?
 
Upvote 0
Maybe a little more detail.

Joe Test.xlsx
ABCDEFGHIJKLM
1NameWeek 1Week 2Week 3Week 4Week 5Week 6Week 7Week 8Week 9Week 10Week20Week 21
2Person1Man UtdSpursMan UtdLiverpoolWest Ham
3Person2Man UtdWest Ham
Sheet1
Cells with Data Validation
CellAllowCriteria
B2:K3Custom=COUNTIF(INDIRECT($A2),B2)=1


Row 3 has a Custom Data Validation rule: =COUNTIF(INDIRECT($A3),B3)=1
If you try to enter a duplicate value in row 3 the Data Validation rule will kick in and prevent it.
But the spreadsheet will expand both horizontally (columns) and vertically (rows).
What I am trying to do is have the named ranges (rows) automatically expand to incorporate newly added columns. I came up with:
Excel Formula:
="Sheet1!$B$2:" & "Sheet1!" & ADDRESS(2,COLUMNS(DataTable),1)
which worked as a formula in the spreadsheet; result for Row 3: Sheet1!$B$2:Sheet1!$M$2. If I add a column this expands to: Sheet1!$B$2:Sheet1!$N$2.
Then the Custom Data Validation rule would pick the Named Range from A3 (see Custom Data Validation rule above).

In this way it would be a simple matter of creating a Named Range for each persons name in column A. When adding a new row to the table the Data Validation will automatically be created in the new row. Similarly for the addition of a new column.

The problem I am having is defining the Named Range. I want it to be dynamic. i.e. the Named Range "Person1" could be B3:H3 or B3:I3 or B3:J3 etc. It's not working for me.

@arthurbr; maybe I am over complicating this and there is an easier way to utilise the table structure to accomplish what I want?
@rakesh seebaruth; the INDEX formula did not work for me but it's possible my setup elsewhere is incorrect for this approach. Maybe the detail above will clarify?
 
Upvote 0
Change it to:

Excel Formula:
="Sheet1!$B$2:" & ADDRESS(2,COLUMNS(DataTable),1)
 
Upvote 0
@RoryA that doesn't appear to work.

="Sheet1!$B$2:" & ADDRESS(2,COLUMNS(DataTable),1) as the reference for the Named Range along with =COUNTIF(INDIRECT($A2),C2)=1 as the Data Validation rule prevents the addition of ANY text into the cells in row 2.
The "Value" isn't populated in the "Name Manager" when entering the formula above. Not sure if this is significant.
1675428059482.png


Also, when I enter the "Data Validation" rule I get the message: "The formula currently evaluates to an error. Do you want to continue?"
Again, not sure if this is significant.
 
Upvote 0
Does anyone have any further thoughts on this?
I feel it's either impossible to achieve or not too far away.
But after trying numerous different approaches I still can't get it to work.
 
Upvote 0
Looking closer at your setup, INDIRECT is not going to work (Person1 returns text, not a range).

You could create a name called TableRange and assign your table to it. Then use the following in the data validation formula:

Excel Formula:
=COUNTIF(INDEX(TableRange,ROW(B2)-ROW(TableRange)+1,0),B2)=1

Make sure you uncheck the 'Ignore blank' option.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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