Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default creating validation list in VBA

Hi All,

When I create a validation list manually, I get a message saying "Evaluating
source cause an error! Do you want to continue?". If I reply Yes, XL2003
creates the data validation list, and I can choose new values from the
validation source.
If I want to create the same validation list in VBA, I get a run-time error
message. On Error Resume Next doesn't help, it skips the .Add
Type:=xlValidateList, ... etc. line, but doesn't create the validation.
How can I tell VBA to behave itself like XL user interface?

Thanks,
Stefi

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default creating validation list in VBA

I can't be sure as I don't have 2003 but try adding

Application.DisplayAlerts = False

before the code and reset to True after.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Stefi" wrote in message
...
Hi All,

When I create a validation list manually, I get a message saying

"Evaluating
source cause an error! Do you want to continue?". If I reply Yes, XL2003
creates the data validation list, and I can choose new values from the
validation source.
If I want to create the same validation list in VBA, I get a run-time

error
message. On Error Resume Next doesn't help, it skips the .Add
Type:=xlValidateList, ... etc. line, but doesn't create the validation.
How can I tell VBA to behave itself like XL user interface?

Thanks,
Stefi



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default creating validation list in VBA

Thanks for your reply Bob, but it didn't help! But I made some tests and
found the following strange behaviour:

My source list is defined by an OFFSET function that contains a MATCH
function using the reference of the adjacent cell. When this function can be
evaluated for the FIRST cell of the range I want to apply the validation to,
VBA creates the validation for the WHOLE range, even if the function returns
an Error for the remaining cells. Otherwise it stops with a 1004 Run-time
error message.

I made a workaround by adding an extra first row with values ensuring
correct evaluation of the OFFSET and MATCH functions though I am not sure
wether this is the best solution!

Regards,
Stefi

€žBob Phillips€ ezt Ã*rta:

I can't be sure as I don't have 2003 but try adding

Application.DisplayAlerts = False

before the code and reset to True after.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Stefi" wrote in message
...
Hi All,

When I create a validation list manually, I get a message saying

"Evaluating
source cause an error! Do you want to continue?". If I reply Yes, XL2003
creates the data validation list, and I can choose new values from the
validation source.
If I want to create the same validation list in VBA, I get a run-time

error
message. On Error Resume Next doesn't help, it skips the .Add
Type:=xlValidateList, ... etc. line, but doesn't create the validation.
How can I tell VBA to behave itself like XL user interface?

Thanks,
Stefi




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default creating validation list in VBA

Stefi,

what is the formula, I would like to try and replicate?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Stefi" wrote in message
...
Thanks for your reply Bob, but it didn't help! But I made some tests and
found the following strange behaviour:

My source list is defined by an OFFSET function that contains a MATCH
function using the reference of the adjacent cell. When this function can

be
evaluated for the FIRST cell of the range I want to apply the validation

to,
VBA creates the validation for the WHOLE range, even if the function

returns
an Error for the remaining cells. Otherwise it stops with a 1004 Run-time
error message.

I made a workaround by adding an extra first row with values ensuring
correct evaluation of the OFFSET and MATCH functions though I am not sure
wether this is the best solution!

Regards,
Stefi

"Bob Phillips" ezt írta:

I can't be sure as I don't have 2003 but try adding

Application.DisplayAlerts = False

before the code and reset to True after.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Stefi" wrote in message
...
Hi All,

When I create a validation list manually, I get a message saying

"Evaluating
source cause an error! Do you want to continue?". If I reply Yes,

XL2003
creates the data validation list, and I can choose new values from the
validation source.
If I want to create the same validation list in VBA, I get a run-time

error
message. On Error Resume Next doesn't help, it skips the .Add
Type:=xlValidateList, ... etc. line, but doesn't create the

validation.
How can I tell VBA to behave itself like XL user interface?

Thanks,
Stefi






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default creating validation list in VBA

..Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:= _

"=OFFSET(OMSZ,1,MATCH(D2,OFFSET(OMSZ,0,0,1,COLUMNS (OMSZ)),0)-1,COUNTA(OFFSET(OMSZ,1,MATCH(D2,OFFSET(OMSZ,0,0,1, COLUMNS(OMSZ)),0)-1,ROWS(OMSZ),1)),1)"

where OMSZ is a range name referring to a sheet containing county names in
the first row and settlements names located in that county under them. The
basic idea is to group settlements into counties then enter a county name in
column D and choose a settlement (column E) from the list of settlements
located in that county.

In fact County names are also chosen from a validation list rather than
typed in:

..Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=OFFSET(OMSZ,0,0,1,COLUMNS(OMSZ))"

I'm looking forward to the result of your testing!
Regards,
Stefi

€žBob Phillips€ ezt Ã*rta:

Stefi,

what is the formula, I would like to try and replicate?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Stefi" wrote in message
...
Thanks for your reply Bob, but it didn't help! But I made some tests and
found the following strange behaviour:

My source list is defined by an OFFSET function that contains a MATCH
function using the reference of the adjacent cell. When this function can

be
evaluated for the FIRST cell of the range I want to apply the validation

to,
VBA creates the validation for the WHOLE range, even if the function

returns
an Error for the remaining cells. Otherwise it stops with a 1004 Run-time
error message.

I made a workaround by adding an extra first row with values ensuring
correct evaluation of the OFFSET and MATCH functions though I am not sure
wether this is the best solution!

Regards,
Stefi

"Bob Phillips" ezt Ã*rta:

I can't be sure as I don't have 2003 but try adding

Application.DisplayAlerts = False

before the code and reset to True after.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Stefi" wrote in message
...
Hi All,

When I create a validation list manually, I get a message saying
"Evaluating
source cause an error! Do you want to continue?". If I reply Yes,

XL2003
creates the data validation list, and I can choose new values from the
validation source.
If I want to create the same validation list in VBA, I get a run-time
error
message. On Error Resume Next doesn't help, it skips the .Add
Type:=xlValidateList, ... etc. line, but doesn't create the

validation.
How can I tell VBA to behave itself like XL user interface?

Thanks,
Stefi









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default creating validation list in VBA

Stefi,

I have tested it on XL2000 and 2002 and it fails. Even if I wrap in On Error
Resume Next, although it runs, no list gets created.

I will play some more over the weekend.

There is something odd about the formula, so I wonder if I am reading it
correctly. Can you send me a workbook, with the failing formula and one with
the workaround that I can play with?


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Stefi" wrote in message
...
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:= _


"=OFFSET(OMSZ,1,MATCH(D2,OFFSET(OMSZ,0,0,1,COLUMNS (OMSZ)),0)-1,COUNTA(OFFSET
(OMSZ,1,MATCH(D2,OFFSET(OMSZ,0,0,1,COLUMNS(OMSZ)), 0)-1,ROWS(OMSZ),1)),1)"

where OMSZ is a range name referring to a sheet containing county names in
the first row and settlements names located in that county under them. The
basic idea is to group settlements into counties then enter a county name

in
column D and choose a settlement (column E) from the list of settlements
located in that county.

In fact County names are also chosen from a validation list rather than
typed in:

.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=OFFSET(OMSZ,0,0,1,COLUMNS(OMSZ))"

I'm looking forward to the result of your testing!
Regards,
Stefi

"Bob Phillips" ezt írta:

Stefi,

what is the formula, I would like to try and replicate?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Stefi" wrote in message
...
Thanks for your reply Bob, but it didn't help! But I made some tests

and
found the following strange behaviour:

My source list is defined by an OFFSET function that contains a MATCH
function using the reference of the adjacent cell. When this function

can
be
evaluated for the FIRST cell of the range I want to apply the

validation
to,
VBA creates the validation for the WHOLE range, even if the function

returns
an Error for the remaining cells. Otherwise it stops with a 1004

Run-time
error message.

I made a workaround by adding an extra first row with values ensuring
correct evaluation of the OFFSET and MATCH functions though I am not

sure
wether this is the best solution!

Regards,
Stefi

"Bob Phillips" ezt írta:

I can't be sure as I don't have 2003 but try adding

Application.DisplayAlerts = False

before the code and reset to True after.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Stefi" wrote in message
...
Hi All,

When I create a validation list manually, I get a message saying
"Evaluating
source cause an error! Do you want to continue?". If I reply Yes,

XL2003
creates the data validation list, and I can choose new values from

the
validation source.
If I want to create the same validation list in VBA, I get a

run-time
error
message. On Error Resume Next doesn't help, it skips the .Add
Type:=xlValidateList, ... etc. line, but doesn't create the

validation.
How can I tell VBA to behave itself like XL user interface?

Thanks,
Stefi









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Data Validation List based on a Value in another cell LondonLion Excel Worksheet Functions 2 June 8th 07 12:23 AM
Creating a list (data validation) fromt wo different source ranges tony Excel Discussion (Misc queries) 1 August 1st 06 03:40 AM
Creating a Validation List Through Macro pavankks Excel Programming 0 August 11th 04 07:36 PM
Creating a Validation List Through Macro Pavan Kishore K. S.[_2_] Excel Programming 0 August 11th 04 05:07 AM
Validation (Drop down list vs simple text length validation) Pete McCosh Excel Programming 0 April 27th 04 03:49 PM


All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"