annieapplebee
New Member
Hello,
I have a sheet here that I use data validation on all columns in the master list tab, the list is generated in material color tab. How to automatically update the cell when the list change? I tried using macro, pasted this code in the master list worksheet but didn't work.
>>> use code - tags <<<
Your help is appreciated!
Thanks,
AnnieAppleBee
I have a sheet here that I use data validation on all columns in the master list tab, the list is generated in material color tab. How to automatically update the cell when the list change? I tried using macro, pasted this code in the master list worksheet but didn't work.
>>> use code - tags <<<
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strValidationList As String
Dim strVal As String
Dim lngNum As Long
On Error GoTo Nevermind
strValidationList = Mid(Target.Validation.Formula1, 2)
strVal = Target.Value
lngNum = Application.WorksheetFunction.Match(strVal, Range(strValidationList), 0)
If strVal <> "" And lngNum > 0 Then
Application.EnableEvents = False
Target.Formula = "=INDEX(" & strValidationList & ", " & lngNum & ")"
End If
Nevermind:
Application.EnableEvents = True
End Sub
Thanks,
AnnieAppleBee
Attachments
Last edited by a moderator: