Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Validation rules

I uses records macro from Excel to add a new validation.
I copied the code generated by macro to my function, but it fails.

The code is following:

For i = 19 To iRow
For J = 7 To iCol
With Sheets(wsDestination).Cells(i, J).Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="100"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Next J
Next i


I got run time erro 1004


"Unable to get large property of worksheetfunction class"


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Validation rules

Your macro ran for me after I fleshed it out a bit:

Sub a()
Dim i As Integer, J As Integer
Dim iRow As Integer
Dim iCol As Integer
Dim wsDestination As String
wsDestination = "Sheet1"
iRow = 25
iCol = 10
For i = 19 To iRow
For J = 7 To iCol
With Sheets(wsDestination).Cells(i, J).Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop,
_
Operator:=xlBetween, Formula1:="0", Formula2:="100"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Next J
Next i
End Sub

The error message you reported cannot have anything to do with the code you
posted since it does not use the Large worksheet function. You're running
some other sub I think. Btw, there is no reason to iterate through the
cells in the range one at a time. You can apply the validation to all of
them at once:

Sub aa()
Dim iRow As Integer
Dim iCol As Integer
Dim wsDestination As String
wsDestination = "Sheet1"
iRow = 25
iCol = 10
With Sheets(wsDestination).Cells(19, 7).Resize(iRow - 19 + 1, iCol - 7 +
1).Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="100"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = "I think you need some kind of message don't you?"
.ShowInput = True
.ShowError = True
End With
End Sub



--
Jim
"Souris" wrote in message
...
I uses records macro from Excel to add a new validation.
I copied the code generated by macro to my function, but it fails.

The code is following:

For i = 19 To iRow
For J = 7 To iCol
With Sheets(wsDestination).Cells(i, J).Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="100"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Next J
Next i


I got run time erro 1004


"Unable to get large property of worksheetfunction class"




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Validation rules

Thanks millions for the information,

I found the problem:

1. The cell format must be number, can not be general
2. I need select the spreadsheet.
My button and code are on sheet1, but I wanted to fill validation on sheet2.

Thanks again,




"Jim Rech" wrote:

Your macro ran for me after I fleshed it out a bit:

Sub a()
Dim i As Integer, J As Integer
Dim iRow As Integer
Dim iCol As Integer
Dim wsDestination As String
wsDestination = "Sheet1"
iRow = 25
iCol = 10
For i = 19 To iRow
For J = 7 To iCol
With Sheets(wsDestination).Cells(i, J).Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop,
_
Operator:=xlBetween, Formula1:="0", Formula2:="100"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Next J
Next i
End Sub

The error message you reported cannot have anything to do with the code you
posted since it does not use the Large worksheet function. You're running
some other sub I think. Btw, there is no reason to iterate through the
cells in the range one at a time. You can apply the validation to all of
them at once:

Sub aa()
Dim iRow As Integer
Dim iCol As Integer
Dim wsDestination As String
wsDestination = "Sheet1"
iRow = 25
iCol = 10
With Sheets(wsDestination).Cells(19, 7).Resize(iRow - 19 + 1, iCol - 7 +
1).Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="100"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = "I think you need some kind of message don't you?"
.ShowInput = True
.ShowError = True
End With
End Sub



--
Jim
"Souris" wrote in message
...
I uses records macro from Excel to add a new validation.
I copied the code generated by macro to my function, but it fails.

The code is following:

For i = 19 To iRow
For J = 7 To iCol
With Sheets(wsDestination).Cells(i, J).Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="100"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Next J
Next i


I got run time erro 1004


"Unable to get large property of worksheetfunction class"





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Validation rules

It works fine for me.

Did you initialise iRow, iCol and wsDestination?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Souris" wrote in message
...
I uses records macro from Excel to add a new validation.
I copied the code generated by macro to my function, but it fails.

The code is following:

For i = 19 To iRow
For J = 7 To iCol
With Sheets(wsDestination).Cells(i, J).Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="100"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Next J
Next i


I got run time erro 1004


"Unable to get large property of worksheetfunction class"




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
Macrs with Validation Rules Chris Excel Worksheet Functions 1 March 10th 10 06:37 PM
making 2 (or more) validation rules for each cell ali Excel Discussion (Misc queries) 2 September 13th 07 04:26 AM
how do I set up a validation rules with two data rules Trudy Excel Worksheet Functions 1 October 16th 06 05:42 AM
Data Validation Rules Louise Excel Worksheet Functions 6 May 10th 06 01:02 PM
Exceptions to Validation Rules Jim Johnson Excel Worksheet Functions 5 November 7th 04 01:04 PM


All times are GMT +1. The time now is 03:43 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"