Courgettey
New Member
- Joined
- Jan 25, 2017
- Messages
- 3
Hello - I am new to posting on here but have found these forums very helpful so hopefully you can help!
I am using a userform with a listbox. The listbox is pre populated. When the user selects an item from the listbox, I would like to search previous outputs (in column C) in the worksheet to see if there are any duplicates, alert the user and stop them from progressing.
My code did work... but then I closed and re-opened my file and it no longer works. Can anyone help or spot where I went wrong?
Code:
I am using a userform with a listbox. The listbox is pre populated. When the user selects an item from the listbox, I would like to search previous outputs (in column C) in the worksheet to see if there are any duplicates, alert the user and stop them from progressing.
My code did work... but then I closed and re-opened my file and it no longer works. Can anyone help or spot where I went wrong?
Code:
Code:
Private Sub ListBox_Click()
With Sheet4.Range("C2:C500")
For ListItem = 0 To ListBox.ListCount - 1
If Asset_List.Selected(ListItem) = True Then
If Selection.Find(What:=ListBox.List(ListItem), LookIn:=xlValues) Is Nothing Then
'
Else
MsgBox "This listbox item has already been submitted, please choose another "
Exit Sub
End If
End If
Next ListItem
End With
End Sub
Last edited by a moderator: