Hi. I am trying to create code that will generate a random number and place it in a specific cell when the drop down list selection in another cell in changed. If the selection in the drop down list is "" or "-", I want the cell with the random number to be blank. A new random number would be generated in the cell only if the drop down list selection changes.
The code I have below does nothing as best I can tell, so I've obviously missed something. Any help would be appreciated!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Low As Double
Dim High As Double
Low = 100000
High = 999999
r = Int((High - Low + 1) * Rnd() + Low)
If Not Intersect(Target, [F22]) Is Nothing Then
On Error Resume Next
Application.EnableEvents = False
If F22 = "-" Or F22 = "" Then
B20 = ""
Else
B20 = r
End If
Application.EnableEvents = True
End If
End Sub
Bookmarks