ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dropd Down (validation: list) on the fly with a code - a problem (https://www.excelbanter.com/excel-programming/404344-dropd-down-validation-list-fly-code-problem.html)

AB[_2_]

Dropd Down (validation: list) on the fly with a code - a problem
 
Hi,

I was hoping if anyone could help me - i'm trying to write a code that
would create a dropdown in a cell on the fly. That's the simple code:

With Selection.Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:="1;2"
.InCellDropdown = True
End With

So far so good, but the problem is that i want the dropdown to let the
user enter either 1 or 2 but if i run the above code then the dropdown
lets the user enter only one value = "1;2".
In the meantime if i enter the same list ("1;2") manualy into the
validation (Datavalidation - i.e., don't do it with a code) - then
everything is fine - i.e., the dropdown offers either value ("1" or
"2") and not the combined ("1;2").

The point is that i'll need to define the dropdown lists on the fly
and they'll constantly change, that's why i wanted to do that with a
code.

Any help would be greatly appreciated.
Thanks!

papou[_4_]

Dropd Down (validation: list) on the fly with a code - a problem
 
Hi AB
Use the comma separator instead, eg:
xlBetween, Formula1:="1,2"

HTh
Cordially
Pascal

"AB" a écrit dans le message de news:
...
Hi,

I was hoping if anyone could help me - i'm trying to write a code that
would create a dropdown in a cell on the fly. That's the simple code:

With Selection.Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:="1;2"
.InCellDropdown = True
End With

So far so good, but the problem is that i want the dropdown to let the
user enter either 1 or 2 but if i run the above code then the dropdown
lets the user enter only one value = "1;2".
In the meantime if i enter the same list ("1;2") manualy into the
validation (Datavalidation - i.e., don't do it with a code) - then
everything is fine - i.e., the dropdown offers either value ("1" or
"2") and not the combined ("1;2").

The point is that i'll need to define the dropdown lists on the fly
and they'll constantly change, that's why i wanted to do that with a
code.

Any help would be greatly appreciated.
Thanks!




AB[_2_]

Dropd Down (validation: list) on the fly with a code - a problem
 
It was so simple...!!
Perfect! THANKS!

I must start using "," as list seperators in my Regional settings, i
believe - otherwise i'll have confusions like this all the time...

Thanks again.

papou[_4_]

Dropd Down (validation: list) on the fly with a code - a problem
 
AB
I must start using "," as list seperators in my Regional settings, i
believe


There is no need for this, I have a semi-colon as list seperator in my
settings.
Just remember VBA has the US settings by design.

HTH
Cordially
Pascal

"AB" a écrit dans le message de news:
...
It was so simple...!!
Perfect! THANKS!

I must start using "," as list seperators in my Regional settings, i
believe - otherwise i'll have confusions like this all the time...

Thanks again.





All times are GMT +1. The time now is 02:43 PM.

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