Prevent duplicates in a range

reaper_2

New Member
Joined
Sep 30, 2010
Messages
18
I know it's pretty simple to prevent duplicates in a column, using data validation or VBA - but how do you do it across multiple cells?

say I've got a spreadsheet where A2 is Surname, B2 is Forename, and C2 is a date value, I want to prevent users duplicating all three.

So each column can contain duplicates, but there cannot be the same combination of each three appearing more than once. The simplest thing I though would be to concatenate (A2,B2,C2) and stick custom validation on the resulting formula, but that didn't seem to work. I've also tried a few VBA bits I picked up from various online places but they all relate to single columns it seems.

any ideas?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi
If you are using Excel 2007 or 2010 then you can use Countifs function through Data Validation for the same like, but put Data Validation in last col.

Code:
=COUNTIFS($E$1:$E$7,E2,$F$1:$F$7,F2,$G$1:$G$7,G2)=1
 
Upvote 0
thanks, we're using 2003 I'm afraid.

Also - there is already validation on column C to ensure the date value is entered correctly. Therefore can't add custom validation to this one.

Does anybody know hoe to achieve this with VBA?

ta
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,713
Members
452,939
Latest member
WCrawford

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