Professional Documents
Culture Documents
Both macros listed below add drop down menus or lists to cells in Excel; but, but the first
one will add a drop down menu to a specific cell that you hard code into the macro whereas
the second macro adds a drop down menu into any cell that has been selected before the
macro is run.
Excel Data Validation Macro that Adds a Drop Down Menu to a Specific
Cell in Excel
Sub Add_Drop_Down_Menu_Cell()
With Range("A1").Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween,
_
Formula1:="=$D$1:$D$3"
.IgnoreBlank = True
.InCellDropdown = True
End With
End Sub
Excel Data Validation Macro that Adds a Drop Down Menu to a Selected
Cell in Excel
Sub Add_Drop_Down_Menu_Selection()
With Selection.Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween,
_
Formula1:="=$D$1:$D$3"
.IgnoreBlank = True
.InCellDropdown = True
End With
End Sub
1. Select and copy the text from within the grey box above.
2. Open the Microsoft Excel file in which you would like the Macro to function.
3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel
Versions. Or For other ways to get there, Click Here.
4. On the new window that opens up, go to the left side where the vertical pane is
located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME
HERE) and click this.
7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.
8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you
close the Visual Basic Editor window, the regular Excel window will not close.