I have a cell with a validation drop down. I also have the code below that applies formatting to a range depending on the value chosen in the validation cell.
The problem is that validation enters the value. But doesn’t “Press Enter” afterwards. So the vba won’t pick up the value and run.
I’ve tried using a separate combo box, SendKeys ~, SendKeys ENTER etc but still can’t think of a way to do it.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$2" And Target = "Dogs" Then
Range("Row18").Select
Selection.NumberFormat = "0.00%"
End If
If Target.Address = "$B$2" And Target = "Cats" Then
Range("Row18").Select
Selection.NumberFormat = "0"
End If
End Sub
The problem is that validation enters the value. But doesn’t “Press Enter” afterwards. So the vba won’t pick up the value and run.
I’ve tried using a separate combo box, SendKeys ~, SendKeys ENTER etc but still can’t think of a way to do it.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$2" And Target = "Dogs" Then
Range("Row18").Select
Selection.NumberFormat = "0.00%"
End If
If Target.Address = "$B$2" And Target = "Cats" Then
Range("Row18").Select
Selection.NumberFormat = "0"
End If
End Sub