Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Possible Validation.Modify bug in Excel 2000

Hello,

I have a Data Validation in a cell say D5 of type xlValidateList.

I modify this validation in VBA:

sub foo ()
Range("d5").Validation _
.Modify Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Formula1:="Apple,Orange,Mango"
end sub

This works when run from the VB Editor.

If I create a Control Toolbox button and put the same code in say :
CommandButton1_Click it does not work.
Says "Application-Defined or Object-Defined error"

Again if I create a Forms Button and put the same code in the macro
assigned to the button it works.

Why doesn't it work when triggered from the Control Toolbox Button?

Regards
Gap

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Possible Validation.Modify bug in Excel 2000

You need to ensure a cell range is selected when you run that code.

If you run the code from a worksheet control set its TakeFocusOnClick
property to false.

However, as the code would also fail if any other type of object is
selected, perhaps select some cell as the first line of your code, eg

ActiveWindow.VisibleRange(1, 1).Select

Regards,
Peter T

wrote in message
oups.com...
Hello,

I have a Data Validation in a cell say D5 of type xlValidateList.

I modify this validation in VBA:

sub foo ()
Range("d5").Validation _
.Modify Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Formula1:="Apple,Orange,Mango"
end sub

This works when run from the VB Editor.

If I create a Control Toolbox button and put the same code in say :
CommandButton1_Click it does not work.
Says "Application-Defined or Object-Defined error"

Again if I create a Forms Button and put the same code in the macro
assigned to the button it works.

Why doesn't it work when triggered from the Control Toolbox Button?

Regards
Gap



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Possible Validation.Modify bug in Excel 2000

I couldn't reproduce the problem. did you add the code into the sheet code
module?

--
---
HTH

Bob

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



wrote in message
oups.com...
Hello,

I have a Data Validation in a cell say D5 of type xlValidateList.

I modify this validation in VBA:

sub foo ()
Range("d5").Validation _
.Modify Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Formula1:="Apple,Orange,Mango"
end sub

This works when run from the VB Editor.

If I create a Control Toolbox button and put the same code in say :
CommandButton1_Click it does not work.
Says "Application-Defined or Object-Defined error"

Again if I create a Forms Button and put the same code in the macro
assigned to the button it works.

Why doesn't it work when triggered from the Control Toolbox Button?

Regards
Gap



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Possible Validation.Modify bug in Excel 2000

Hi Bob,

I could replicate the problem in XL2000 & XL97

As I mentioned, if the selection while running the code is not a Range, eg a
Controls button with focus or a Rectangle, the code fails for me. Not only
with the OP's particular code but whenever adding or modifying the DV.

Regards,
Peter T


"Bob Phillips" wrote in message
...
I couldn't reproduce the problem. did you add the code into the sheet

code
module?

--
---
HTH

Bob

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

addy)



wrote in message
oups.com...
Hello,

I have a Data Validation in a cell say D5 of type xlValidateList.

I modify this validation in VBA:

sub foo ()
Range("d5").Validation _
.Modify Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Formula1:="Apple,Orange,Mango"
end sub

This works when run from the VB Editor.

If I create a Control Toolbox button and put the same code in say :
CommandButton1_Click it does not work.
Says "Application-Defined or Object-Defined error"

Again if I create a Forms Button and put the same code in the macro
assigned to the button it works.

Why doesn't it work when triggered from the Control Toolbox Button?

Regards
Gap





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Possible Validation.Modify bug in Excel 2000

Yes the code is in the Sheet.

On Feb 8, 5:59 pm, "Bob Phillips" wrote:
I couldn't reproduce the problem. did you add the code into the sheet code
module?

--
---
HTH

Bob

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

wrote in message

oups.com...





Hello,


I have a Data Validation in a cell say D5 of type xlValidateList.


I modify this validation in VBA:


sub foo ()
Range("d5").Validation _
.Modify Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Formula1:="Apple,Orange,Mango"
end sub


This works when run from the VB Editor.


If I create a Control Toolbox button and put the same code in say :
CommandButton1_Click it does not work.
Says "Application-Defined or Object-Defined error"


Again if I create a Forms Button and put the same code in the macro
assigned to the button it works.


Why doesn't it work when triggered from the Control Toolbox Button?


Regards
Gap





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Possible Validation.Modify bug in Excel 2000

On Feb 8, 4:15 pm, "Peter T" <peter_t@discussions wrote:
You need to ensure a cell range is selected when you run that code.

If you run the code from a worksheet control set its TakeFocusOnClick
property to false.

However, as the code would also fail if any other type of object is
selected, perhaps select some cell as the first line of your code, eg

ActiveWindow.VisibleRange(1, 1).Select

Regards,
Peter T

wrote in message

oups.com...

Hello,


I have a Data Validation in a cell say D5 of type xlValidateList.


I modify this validation in VBA:


sub foo ()
Range("d5").Validation _
.Modify Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Formula1:="Apple,Orange,Mango"
end sub


This works when run from the VB Editor.


If I create a Control Toolbox button and put the same code in say :
CommandButton1_Click it does not work.
Says "Application-Defined or Object-Defined error"


Again if I create a Forms Button and put the same code in the macro
assigned to the button it works.


Why doesn't it work when triggered from the Control Toolbox Button?


Regards
Gap


Thanks Peter, your solution of "Select"ing the range works. (Since
there are other object on the sheet that could be selected). Sometimes
it confuses the user though.

Would you call this a workaround to the problem or thats how it should
be done?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Possible Validation.Modify bug in Excel 2000

Try using

Activecell.Select

instead, that shouldn't confuse.

--
---
HTH

Bob

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



wrote in message
ps.com...
On Feb 8, 4:15 pm, "Peter T" <peter_t@discussions wrote:
You need to ensure a cell range is selected when you run that code.

If you run the code from a worksheet control set its TakeFocusOnClick
property to false.

However, as the code would also fail if any other type of object is
selected, perhaps select some cell as the first line of your code, eg

ActiveWindow.VisibleRange(1, 1).Select

Regards,
Peter T

wrote in message

oups.com...

Hello,


I have a Data Validation in a cell say D5 of type xlValidateList.


I modify this validation in VBA:


sub foo ()
Range("d5").Validation _
.Modify Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Formula1:="Apple,Orange,Mango"
end sub


This works when run from the VB Editor.


If I create a Control Toolbox button and put the same code in say :
CommandButton1_Click it does not work.
Says "Application-Defined or Object-Defined error"


Again if I create a Forms Button and put the same code in the macro
assigned to the button it works.


Why doesn't it work when triggered from the Control Toolbox Button?


Regards
Gap


Thanks Peter, your solution of "Select"ing the range works. (Since
there are other object on the sheet that could be selected). Sometimes
it confuses the user though.

Would you call this a workaround to the problem or thats how it should
be done?



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
Excel 2000 Validation with colors MR.WJCA Excel Discussion (Misc queries) 1 September 3rd 08 05:03 PM
Modify Yearly Calendar to Monthly Calendar Excel 2000? James Cooper Excel Programming 13 July 13th 06 11:46 PM
Validation in Excel 2000 JessKates Setting up and Configuration of Excel 0 August 25th 05 07:57 PM
data validation in excel 2000 Sam Excel Programming 0 September 23rd 03 01:44 PM
data validation in excel 2000 Sam Excel Programming 1 July 23rd 03 11:24 AM


All times are GMT +1. The time now is 07:40 AM.

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

About Us

"It's about Microsoft Excel"