Link to home
Start Free TrialLog in
Avatar of hindersaliva
hindersalivaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Excel VBA - fill in-cell dropdown

I'm using this to loop 5 times to fill an in-cell dropdown.

Sub Add_Drop_Down_Menu_Selection()

    For i = 1 To 5
    
        With Selection.Validation
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _
        Formula1:="MyData"
        .IgnoreBlank = True
        .InCellDropdown = True
        End With

    Next i

End Sub

Open in new window


But I get Runtime error 1004.
It works fine for the 1st run through the loop. I want it to ADD more items until the loop ends.

Thanks!
SOLUTION
Avatar of Saurabh Singh Teotia
Saurabh Singh Teotia
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial