#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default Avoiding Duplicates

If i have a range of cells from A1:A100 and the same drop down list of names
in each of those 100 cells how do i prevent staff from selecting the same
name twice within that range?

For example i want to avoid someone selecting a name in cell A3 and then
selecting the same name further down the spreadsheet at say A70.

Is it also possible to display a message saying that a duplication has been
attempted?

Thanks in advance
Craig
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default Avoiding Duplicates

Data validation is used for drop down list therefore you need an event macro
for that:

Private Sub Worksheet_Change(ByVal Target As Range)
If WorksheetFunction.CountIf(Columns(Target.Column), Target) 1 Then
MsgBox "Duplication"
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
End If
End Sub

Post if you need help to install it!
Regards,
Stefi

€˛Craig€¯ ezt Ć*rta:

If i have a range of cells from A1:A100 and the same drop down list of names
in each of those 100 cells how do i prevent staff from selecting the same
name twice within that range?

For example i want to avoid someone selecting a name in cell A3 and then
selecting the same name further down the spreadsheet at say A70.

Is it also possible to display a message saying that a duplication has been
attempted?

Thanks in advance
Craig

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default Avoiding Duplicates

Hi Stefi,

I've never ran an event macro before. How to i go about it?

Thanks

"Craig" wrote:

If i have a range of cells from A1:A100 and the same drop down list of names
in each of those 100 cells how do i prevent staff from selecting the same
name twice within that range?

For example i want to avoid someone selecting a name in cell A3 and then
selecting the same name further down the spreadsheet at say A70.

Is it also possible to display a message saying that a duplication has been
attempted?

Thanks in advance
Craig

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default Avoiding Duplicates

Sorry for the late answer but I've just now realized that my e-mail
notification doesn't work, I thought there is no answer.
If it's still of interest, here is the answer:

Open VBA (Alt+F11)!
Right click on your worksheet name in the Project explorer window!
Select View code from the popup menu!
Copy/Paste macro code in the code window!

--
Regards!
Stefi



€˛Craig€¯ ezt Ć*rta:

Hi Stefi,

I've never ran an event macro before. How to i go about it?

Thanks

"Craig" wrote:

If i have a range of cells from A1:A100 and the same drop down list of names
in each of those 100 cells how do i prevent staff from selecting the same
name twice within that range?

For example i want to avoid someone selecting a name in cell A3 and then
selecting the same name further down the spreadsheet at say A70.

Is it also possible to display a message saying that a duplication has been
attempted?

Thanks in advance
Craig

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Avoiding Duplicates

How can I make this work on a specific column? I want duplicates to be
allowed in every column except A

Billy

"Stefi" wrote:

Data validation is used for drop down list therefore you need an event macro
for that:

Private Sub Worksheet_Change(ByVal Target As Range)
If WorksheetFunction.CountIf(Columns(Target.Column), Target) 1 Then
MsgBox "Duplication"
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
End If
End Sub

Post if you need help to install it!
Regards,
Stefi

€˛Craig€¯ ezt Ć*rta:

If i have a range of cells from A1:A100 and the same drop down list of names
in each of those 100 cells how do i prevent staff from selecting the same
name twice within that range?

For example i want to avoid someone selecting a name in cell A3 and then
selecting the same name further down the spreadsheet at say A70.

Is it also possible to display a message saying that a duplication has been
attempted?

Thanks in advance
Craig



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Avoiding Duplicates

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 1 Then Exit Sub
If WorksheetFunction.CountIf(Columns(Target.Column), Target) 1 Then
MsgBox "Duplication"
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
End If
End Sub


Gord Dibben MS Excel MVP


On Wed, 9 Dec 2009 04:43:01 -0800, billy
wrote:

How can I make this work on a specific column? I want duplicates to be
allowed in every column except A

Billy

"Stefi" wrote:

Data validation is used for drop down list therefore you need an event macro
for that:

Private Sub Worksheet_Change(ByVal Target As Range)
If WorksheetFunction.CountIf(Columns(Target.Column), Target) 1 Then
MsgBox "Duplication"
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
End If
End Sub

Post if you need help to install it!
Regards,
Stefi

„Craig” ezt ķrta:

If i have a range of cells from A1:A100 and the same drop down list of names
in each of those 100 cells how do i prevent staff from selecting the same
name twice within that range?

For example i want to avoid someone selecting a name in cell A3 and then
selecting the same name further down the spreadsheet at say A70.

Is it also possible to display a message saying that a duplication has been
attempted?

Thanks in advance
Craig


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Avoiding Duplicates

Thanks for the help it worked great!!!

"Gord Dibben" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 1 Then Exit Sub
If WorksheetFunction.CountIf(Columns(Target.Column), Target) 1 Then
MsgBox "Duplication"
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
End If
End Sub


Gord Dibben MS Excel MVP


On Wed, 9 Dec 2009 04:43:01 -0800, billy
wrote:

How can I make this work on a specific column? I want duplicates to be
allowed in every column except A

Billy

"Stefi" wrote:

Data validation is used for drop down list therefore you need an event macro
for that:

Private Sub Worksheet_Change(ByVal Target As Range)
If WorksheetFunction.CountIf(Columns(Target.Column), Target) 1 Then
MsgBox "Duplication"
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
End If
End Sub

Post if you need help to install it!
Regards,
Stefi

€˛Craig€¯ ezt Ć*rta:

If i have a range of cells from A1:A100 and the same drop down list of names
in each of those 100 cells how do i prevent staff from selecting the same
name twice within that range?

For example i want to avoid someone selecting a name in cell A3 and then
selecting the same name further down the spreadsheet at say A70.

Is it also possible to display a message saying that a duplication has been
attempted?

Thanks in advance
Craig


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoiding #N/A Heather Excel Discussion (Misc queries) 4 August 25th 09 08:41 PM
AVOIDING DUPLICATES IN A RANGE OF CELLS Glint Excel Discussion (Misc queries) 11 August 9th 06 11:54 AM
Avoiding Duplicates Mald Excel Discussion (Misc queries) 4 August 1st 06 03:38 PM
Avoiding #value MicroMain Excel Worksheet Functions 2 January 25th 06 05:11 AM
Avoiding #NUM! Bruno Campanini Excel Worksheet Functions 9 September 14th 05 02:34 PM


All times are GMT +1. The time now is 07:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"