Using Table Headers as ranges in Data Validation

prabutr28

New Member
Joined
Apr 1, 2020
Messages
3
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi Members,
I have a table named "Books". My table is very simple with 3 columns.
Book.ID, Book.Name, Book.Author
All i want to do is to avoid duplicate values in Book.ID column of a table using data validation.
I simply used the formula "=COUNTIF(Books[Book.ID],Books[@[Book.ID]])=1".

But it throws formula error window...

What am i doing wrong in this?

My table structure.
Book.IDBook.NameBook.Author
10001Sample Book 1Sample Author 1
10002Sample Book 2Sample Author 2
10001Sample Book 3Sample Author 3
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi & welcome to MrExcel
I don't think you can you table references in data validation.
Assuming Book.ID is in A1 try
=COUNTIF(A$2:A2,A2)=1
 
Upvote 0
I also used " around table names. =COUNTIF("Books[Book.ID]","Books[@[Book.ID]]")=1
Still doesnt work.
 
Upvote 0
Upvote 0
That is using the the table header as a named range & then using the Indirect function. It's not the same as what you are trying to do.
 
Upvote 0
Welcome to the MrExcel board!

Try this data validation in your table. It will not let me enter 10001 or 10002 into cell A4.

20 04 01.xlsm
ABC
1Book.IDBook.NameBook.Author
210001Sample Book 1Sample Author 1
310002Sample Book 2Sample Author 2
4Sample Book 3Sample Author 3
Books
Cells with Data Validation
CellAllowCriteria
A2:A4Custom=COUNTIF(INDIRECT("Books[Book.ID]"),INDIRECT("Books[@[Book.ID]]"))=1
 
Upvote 0
try
=COUNTIF(A$2:A2,A2)=1
Without the table I think it would be preferable to use
=COUNTIF(A:A,A2)=1
if you only look at the rows above, the rule could be broken by going back to edit a previous entry.
 
Upvote 0
I suggest not using data validation here. Instead, let the ID column enumerate itself via formula. Enter this in the Book.ID Column:

=ROW()-ROW(tbl_Books[#Headers])

Just replace tbl_Books with the name of your actual table. You can always customize the formula and number formatting from there.
 
Upvote 0

Forum statistics

Threads
1,215,013
Messages
6,122,694
Members
449,092
Latest member
snoom82

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