Data validationin logical function

Closed
vachee1 Posts 1 Registration date Tuesday September 27, 2011 Status Member Last seen September 27, 2011 - Sep 27, 2011 at 03:54 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Sep 27, 2011 at 09:46 PM
Hello,
i am running EXCEL 2007.
i am trying to make an if statement that accomplishes something like, If c1=b1 then d1 = pick a choice from the data validation list(drop down list) that is from e1 to e5. else pick a choice from the data validation list(drop down list) that is from f1 to f5.
i am new to running macros in excel. pls advise how i need to insert a macro for a particular cell and then copy it to the other cells below it i.e for d2,d3..etc to chk for c2,c3,..etc
thanks

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Sep 27, 2011 at 09:46 PM
try this macro

Sub test()
Dim re As Range, rf As Range
Set re = Range("E1:E5")
Set rf = Range("F1:F5")
If Range("C1") = Range("B1") Then
With Range("D1").Validation
.Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=$E$1:$E$5"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
   End With

Else

With Range("D1").Validation
.Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=$F$1:$F$5"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
   End With

End If
End Sub
0