In the Excel UI you can enter a list-type validation whose list is a formula that results in an error. If you do, a dialog box comes up saying "The Source currently evaluates to an error. Do you want to continue?", and if you say Yes, it will preserve the validation. For example, the Source might be "=OFFSET(A1,0,0,NumValues,1)" where NumValues is the name of a cell that right now is blank or has a value less than 1, but later might be set to 1 or more.
But in VBA, if you encode this, even after an On Error Resume Next statement, the validation doesn't get added.
How can I make that validation stick?
But in VBA, if you encode this, even after an On Error Resume Next statement, the validation doesn't get added.
Code:
Range("NumValues") = 0
On Error Resume Next
Range("B1").Validation.Add xlValidateList, xlValidAlertStop, , "=OFFSET(A1,0,0,NumValues,1)"
How can I make that validation stick?