Just like the title says. I've read numerous posts on how to trigger a worksheet change event upon data validation, but am having a bit of difficulty trying to find something going the other way...in relation to creating a data validation cell when a value is placed within an adjacent cell within a table.
e.g. user places value in cell A (to lastrow) which triggers cell B (to lastrow) to a data validation dropdown. I've set A to be a dynamic named range.
Data validation example:
Private Sub Worksheet_Change(ByVal Target As Range)
' dynamic named range "Test" is range "A" that user inputs a value
If Not Intersect(Target, Range("Test")) Is Nothing Then
On Error Resume Next
Application.EnableEvents = False
Call Valid
Sheets(5).UsedRange.Columns.AutoFit
Application.EnableEvents = True
On Error GoTo 0
End If
End Sub
Sub Valid()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim range1 As Range, rng As Range
Set ws2 = ThisWorkbook.Worksheets("Employee_Contacts")
Set ws1 = ThisWorkbook.Worksheets("Sheet3")
Set range1 = ws1.Range("C2")
' dynamic named range of "Valid" is range B that creates a data validation list
Set rng = ws2.Range("Valid").Rows
With rng.Validation
.Delete 'delete previous validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="='" & ws1.Name & "'!" & range1.Address
End With
End Sub
Much appreciated
Bookmarks