Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Trying to demo Code, but get error

On page 189 of Excel 2003 Programming - Inside/Out an
Example is given to set Validation criteria for 10 cells in Column C

Before Entering anything into cells C2:C11 I created (in a std module):

Sub Tester()
With ActiveSheet.Range("C2:C11").Validation
..Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlLessEqual, Formula1:="5000"
..InputTitle = "Credit Limit"
..ErrorTitle = "Credit Limit too High"
..InputMessage = "Enter the Customer's Credit Limit."
..ErrorMessage = "The Credit limit must be less than $5,000."
End With
End Sub

Stepping thru the code I get a R/T error 1004;
Can anyone assist me in determining why?

There doesn't seem to be any errata available for this book.

TIA,

Jim May

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Trying to demo Code, but get error

Jim,

It worked fine for me.

Is the worksheet protected perchance?

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"JMay" wrote in message
...
On page 189 of Excel 2003 Programming - Inside/Out an
Example is given to set Validation criteria for 10 cells in Column C

Before Entering anything into cells C2:C11 I created (in a std module):

Sub Tester()
With ActiveSheet.Range("C2:C11").Validation
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlLessEqual, Formula1:="5000"
.InputTitle = "Credit Limit"
.ErrorTitle = "Credit Limit too High"
.InputMessage = "Enter the Customer's Credit Limit."
.ErrorMessage = "The Credit limit must be less than $5,000."
End With
End Sub

Stepping thru the code I get a R/T error 1004;
Can anyone assist me in determining why?

There doesn't seem to be any errata available for this book.

TIA,

Jim May



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Trying to demo Code, but get error

If I ran it a second time, I got an error -- it's trying to add validation rules
to a range that already has rules.

But you could add a line to delete any existing rules before you add the new
ones:

With ActiveSheet.Range("C2:C11").Validation
.Delete
....rest of code

JMay wrote:

On page 189 of Excel 2003 Programming - Inside/Out an
Example is given to set Validation criteria for 10 cells in Column C

Before Entering anything into cells C2:C11 I created (in a std module):

Sub Tester()
With ActiveSheet.Range("C2:C11").Validation
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlLessEqual, Formula1:="5000"
.InputTitle = "Credit Limit"
.ErrorTitle = "Credit Limit too High"
.InputMessage = "Enter the Customer's Credit Limit."
.ErrorMessage = "The Credit limit must be less than $5,000."
End With
End Sub

Stepping thru the code I get a R/T error 1004;
Can anyone assist me in determining why?

There doesn't seem to be any errata available for this book.

TIA,

Jim May


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Trying to demo Code, but get error

Thanks Guys and A Happy New Year to 'ya
Obviously, I was running more than Once;
The .Delete remedied it

Is there a way I can (In the Immediate window)
Determine the current Validation range (C2:C11)
Like:
? ValidationRange.Address
C2:C11 <<Results

Thanks,

Jim May


" wrote in message
:

If I ran it a second time, I got an error -- it's trying to add validation rules
to a range that already has rules.

But you could add a line to delete any existing rules before you add the new
ones:

With ActiveSheet.Range("C2:C11").Validation
.Delete
....rest of code

JMay wrote:

On page 189 of Excel 2003 Programming - Inside/Out an
Example is given to set Validation criteria for 10 cells in Column C

Before Entering anything into cells C2:C11 I created (in a std module):

Sub Tester()
With ActiveSheet.Range("C2:C11").Validation
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlLessEqual, Formula1:="5000"
.InputTitle = "Credit Limit"
.ErrorTitle = "Credit Limit too High"
.InputMessage = "Enter the Customer's Credit Limit."
.ErrorMessage = "The Credit limit must be less than $5,000."
End With
End Sub

Stepping thru the code I get a R/T error 1004;
Can anyone assist me in determining why?

There doesn't seem to be any errata available for this book.

TIA,

Jim May


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Trying to demo Code, but get error

Never mind; I did the Edit Goto, Special..
To see that it is all there
Thanks Again,
Jim

"JMay" wrote in message
:

Thanks Guys and A Happy New Year to 'ya
Obviously, I was running more than Once;
The .Delete remedied it

Is there a way I can (In the Immediate window)
Determine the current Validation range (C2:C11)
Like:
? ValidationRange.Address
C2:C11 <<Results

Thanks,

Jim May


" wrote in message
:

If I ran it a second time, I got an error -- it's trying to add validation rules
to a range that already has rules.

But you could add a line to delete any existing rules before you add the new
ones:

With ActiveSheet.Range("C2:C11").Validation
.Delete
....rest of code

JMay wrote:

On page 189 of Excel 2003 Programming - Inside/Out an
Example is given to set Validation criteria for 10 cells in Column C

Before Entering anything into cells C2:C11 I created (in a std module):

Sub Tester()
With ActiveSheet.Range("C2:C11").Validation
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlLessEqual, Formula1:="5000"
.InputTitle = "Credit Limit"
.ErrorTitle = "Credit Limit too High"
.InputMessage = "Enter the Customer's Credit Limit."
.ErrorMessage = "The Credit limit must be less than $5,000."
End With
End Sub

Stepping thru the code I get a R/T error 1004;
Can anyone assist me in determining why?

There doesn't seem to be any errata available for this book.

TIA,

Jim May


--

Dave Peterson


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
Can I make my workbook a demo file? Mr BT[_3_] Excel Worksheet Functions 11 August 12th 07 11:58 PM
demo db Andre[_5_] Excel Programming 0 March 10th 06 11:09 PM
Pivot Table Demo vkk0912 Excel Discussion (Misc queries) 1 February 28th 06 10:23 PM
creating a demo that expires after time S. Housley Excel Programming 0 June 24th 04 06:36 PM
Demo of Wheelmouse Scrolling Listboxes Robin Hammond Excel Programming 0 July 16th 03 03:17 AM


All times are GMT +1. The time now is 11:07 PM.

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"