Results 1 to 3 of 3

Run-time Error 1004 with Data Validation

Threaded View

RagonichaFulva Run-time Error 1004 with ... 01-20-2012, 06:42 AM
OnErrorGoto0 Re: Run-time Error 1004 with ... 01-20-2012, 06:46 AM
RagonichaFulva Re: Run-time Error 1004 with ... 01-20-2012, 07:47 AM
  1. #1
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Run-time Error 1004 with Data Validation

    Hello,

    I am trying to use data validation in order to avoid that user write a value higher than 100 nor lesser than 0 in certain cells.

    I previously give format to the cells with the following code:

    Worksheets("Sheet1").Range(Cells(12, 6), Cells(lastrow, 56)).NumberFormat = " #,##0.0%_ ; -#,##0.0%_ ; """"??_ ;_-@_ "
    Let's say that "lastrow" is 50.

    Afterwards, I call the following function:

    Sub aavalidation(lastrow as integer)
    
    Worksheets("Sheet1").Range(Cells(12,6),Cells(lastrow, 56)).Select
    
            With Selection.Validation
                .Delete
                .Add Type:=xlValidateDecimal, AlertStyle:=xlValidAlertInformation, _
                Operator:=xlBetween, Formula1:="0", Formula2:="100"
                .IgnoreBlank = True
                .InCellDropdown = True
                .InputTitle = ""
                .ErrorTitle = "Invalid HC value"
                .InputMessage = ""
                .ErrorMessage = "The HC data you entered isn't a valid value."
                .ShowInput = True
                .ShowError = True
            End With
    
    End Sub
    When this code is executed I receive the 1004 Run-time error (Application-defined or Object Defined Error) and the debugging says that the problem is in:

    .Add Type:=xlValidateDecimal, AlertStyle:=xlValidAlertInformation, _
                Operator:=xlBetween, Formula1:="0", Formula2:="100"
    I would much appreciate your assistance in this issue.
    Last edited by RagonichaFulva; 01-20-2012 at 07:47 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1