I am trying to program a drop down list in a range of individual cells in visual basic. The list will be generated in another range located on the same worksheet. e.g. Cell C1 will have a drop down list from D10:D20 Cell C2 will have a drop down list from E10:E20 etc. The program will cycle through cells in a for x statement and the range will also cycle through a loop. I hope the question is clear.
This will create the data validation lists in cells C1:C20:
Sub CreateDropdowns()
For i = 1 To 20 With Cells(i, 3).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=" & Cells(10, i + 3).Resize(11).Address End With Next
End Sub
Advertisement