MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Running a macro from validation box


Posted by Brian M. on April 10, 2001 1:48 AM

Is it possible to run a macro from the "Yes" or "No" button in a validation box?


Posted by Dave Hawley on April 10, 2001 1:55 AM


Hi Brian

Not too sure what you mean by "button in a validation box" but you can have a macro run on changing from yes to no.

Right click on your sheet name tab and select "View Code", paste in this code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Address = "$A$1" Then
Select Case Target
Case "Yes"
Run "Macro1"
Case "No"
Run "Macro2"
End Select
End If
End Sub


Dave


OzGrid Business Applications

Posted by Brian M. on April 10, 2001 2:11 AM

Posted by Brian M. on April 10, 2001 2:14 AM

Didn't work. I'm trying to run a macro when I click on the Yes button in a data validation dialogue box, I'm sure it's pretty basic.