I have a question that does not require any code. Let's say in Excel you set a data validation on a cell, and insert a drop down of specific values for the user to select from that cell. Let's say also that in VBA you are designating that cell a value from a DB. If the value from the DB does not match any of the values you have designated in the drop-down, will it populate the value in the cell? Or will it just leave it blank? Does anyone have experience with this?
1 Answer
Code will ignore the DV settings and simply populate it anyway. If you need to test afterwards whether it's valid data, check the Validation.Value and see if it's True:
With Range("T1") .Value = "maybe" If .Validation.Value Then MsgBox "Valid entry" Else MsgBox "Invalid entry" .ClearContents End If End With for example.
Validation.Valueand see if it's True.Validation.Value.