ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   data validation and named range (https://www.excelbanter.com/excel-programming/393332-data-validation-named-range.html)

greg

data validation and named range
 
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




Bob Phillips

data validation and named range
 
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)



"greg" wrote in message
...
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







All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com