Code for validation in B column is given in Worksheet event. I have added my code at the end of your code.
Column A validation is not possible as you have shown. Type manually in A column. I have removed validation for column A.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & ", " & Newvalue
Else:
Target.Value = Oldvalue
End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
'Validation for B column
If Not Intersect(Target, Range("A:A")) Is Nothing And Target.Cells.Count = 1 Then
Dim S As String
Dim M, A
Dim T As Long, Ta As Long
Application.EnableEvents = False
M = Target.Value
A = Sheets("Data").Range("A1").CurrentRegion.Offset(1, 0)
With CreateObject("Scripting.dictionary")
For Ta = 1 To UBound(A, 1) - 1
If InStr(1, M, A(Ta, 1)) > 0 Then .Add Ta, A(Ta, 2)
Next Ta
N = .items
M = N(0)
End With
With Target.Offset(0, 1).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(N, ",")
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Application.EnableEvents = True
End If
End Sub
Bookmarks