#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 47
Default Duplicates in lists

I have a user form that has a cell for entering name. I want to be able to
enter data using a dropdown or type in a new value that gets added to the
dropdown. I do not want to see duplicates in the dropdown.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Duplicates in lists

Maybe you could keep track of the list of names in a range on a hidden sheet.
Then you could use application.match() to see if the proposed name already
exists.

Gizmo wrote:

I have a user form that has a cell for entering name. I want to be able to
enter data using a dropdown or type in a new value that gets added to the
dropdown. I do not want to see duplicates in the dropdown.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 747
Default Duplicates in lists

Assuming NameList is a named range a containing a header followed by the
names. The first item is not added to the combobox list because it is the
header:-

Private Sub UserForm_Activate()
Dim i As Integer
With Range("NameList")
For i = 2 To .Count
ComboBox1.AddItem .Item(i).Value
Next
End With
End Sub

Private Sub ComboBox1_AfterUpdate()
With ComboBox1
If .Text < "" And NotInList(.Text) Then .AddItem (.Text) _
Else MsgBox "Permission denied. In list already !!!"
End With
End Sub

Function NotInList(nm As String) As Boolean
Dim i As Integer
Dim found As Boolean
With ComboBox1
For i = 0 To .ListCount - 1
If nm = .List(i) Then
found = True
Exit For
End If
Next
End With
NotInList = Not found
End Function

Greg
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
How to clear validation lists based on other validation lists Ben Excel Discussion (Misc queries) 1 March 12th 07 07:11 PM
LISTS- adding info without repeat to other lists Jemimastar Excel Discussion (Misc queries) 1 December 1st 06 09:29 PM
Lists referencing lists...is it possible? JohnB Excel Worksheet Functions 2 October 18th 06 06:37 PM
Multiple lists with repeated values for dependet drop down lists mcmanusb Excel Worksheet Functions 1 September 29th 06 12:13 AM
lists from other lists in excel Lew Excel Worksheet Functions 5 March 13th 06 07:21 PM


All times are GMT +1. The time now is 05:45 AM.

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"