'refreshing dropdown list when source data changes

I am using the code below

Private Sub Worksheet_Activate()

MainSh.Range("D2").Select With Selection.Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _ Operator:=xlBetween, Formula1:="=MASTER!$A$1:$A$3" End With

MainSh.Range("D2").Value = MasterSh.Range("$A$1").Value

End Sub

The Master sheet contained the data used in the dropdown list appearing on the Main page. When a change is made to the Master sheet data it does not automatically make a change to the drop list unless clicking on the main sheet. I would like this to happen automatically with moving between Main and Master sheets.

While this works it only activates when switching between sheets in workbook. Is there an additional code I can add to make this update automatically?

I have 0 VBA code experience!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source