Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Avoiding #N/A | Excel Discussion (Misc queries) | |||
AVOIDING DUPLICATES IN A RANGE OF CELLS | Excel Discussion (Misc queries) | |||
Avoiding Duplicates | Excel Discussion (Misc queries) | |||
Avoiding #value | Excel Worksheet Functions | |||
Avoiding #NUM! | Excel Worksheet Functions |