A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
For data validation, I used the list option, with the source being
=NameList
To create a dynamic named range, insert a name NameList and have it refer to the formula
=OFFSET(Lists!$A$1,1,0,COUNTA(Lists!$A:$A)-1,1)"
As items are added, the list expands, and the DV list will be updated.
And this will allow you to delete entries:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
Dim lUsed As Long
Dim ws As Worksheet
Dim i As Integer
If Target.Cells.Count > 1 Then Exit Sub
If Target.Column < 5 Or Target.Column > 8 Then Exit Sub
If Target.Value = "" Then Exit Sub
On Error Resume Next
Set ws = Worksheets("Lists")
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Not Intersect(Target, rngDV) Is Nothing Then
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
If oldVal = "" Then
Target.Value = newVal
Else
lUsed = InStr(1, oldVal, newVal)
If lUsed > 0 Then
If Right(oldVal, Len(newVal)) = newVal Then
Target.Value = Left(oldVal, Len(oldVal) - Len(newVal) - 2)
Else
Target.Value = Replace(oldVal, newVal & ", ", "")
End If
Else
Target.Value = oldVal _
& ", " & newVal
End If
End If
If newVal <> "" And Application.WorksheetFunction.CountIf(ws.Range("NameList"), newVal) = 0 Then
i = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row + 1
ws.Range("A" & i).Value = newVal
ws.Range("NameList").Sort Key1:=ws.Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub