Results 1 to 4 of 4

Range.Validation Add Fails with 1004 error

Threaded View

  1. #1
    Registered User
    Join Date
    01-13-2009
    Location
    Israel
    MS-Off Ver
    Excel 2007
    Posts
    8

    Question Range.Validation Add Fails with 1004 error

    Hi,

    I have a strange problem with my Excel Macro.
    I am using the following code in the Worksheet Change event routine:


            Category = "=EmptyList"
            With Worksheets(5).Cells(9, 3).Validation
                .Delete
                .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                xlBetween, Formula1:=Category
                .IgnoreBlank = True
                .InCellDropdown = True
                .InputTitle = ""
                .ErrorTitle = ""
                .InputMessage = ""
                .ErrorMessage = ""
                .ShowInput = True
                .ShowError = True
            End With
    The purpose of this code is to assign a data validation of type list to a cell.

    The code is working just fine when it is activated from the Worksheet Change event routine. However, when I am copying this exact code to a regular routine (that is part of a Module) - I get the following error:

    Run time error 1004: Application-defined or object-defined error.

    What do I do wrong???!!!!

    Please help!

    p.s. I am using Excel 2007
    Last edited by Hila; 01-14-2009 at 08:50 AM. Reason: add code tag as requested

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