data validation and named range

G

greg

Hello,
I am trying to create a data validation drop down. To a named range.

Range(strRange).Select
Range(strRange).Validation.Delete
Range(strRange).Validation.Add Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=" &
strNamedRange



However the named range has not yet been created.
Is there a way to assign the data validation. Then later create the range.
and fill the range.
then somehow do an update to the validation?

thanks
 
B

Bob Phillips

No, the DV creation fails if the name range doesn't exist.

But you could temporarily create it and point it at the DV cell

Range(strRange).Select
Range(strRange).Name = strNamedRange
Range(strRange).Validation.Delete
Range(strRange).Validation.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:="=" & strNamedRange
ThisWorkbook.Names(strNamedRange).Delete


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top