+ Reply to Thread
Results 1 to 2 of 2

Runtime Error 1004 Question

  1. #1
    Registered User
    Join Date
    09-08-2011
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    20

    Runtime Error 1004 Question

    Hi all, I am working on a project currently where I need to have 5 check boxes linked to a macro of different document type. However when i assigned each check box a macro and click each one. I receive a Runtime Error "1004" object defined or application defined error as it reference the line "ActiveSheet.Range ("B70:H70").Validation.Add xlValidateList, , , "=$N$2:$N$99" as the problem. My initial guess is that the range selected for this is too big but I am not quite sure the problem is......

    Sub CheckBox_Financial_Statement_Annual_Click()
    Dim PassVar As String
    PassVar = "test"
    ActiveSheet.Unprotect PassVar
    If ActiveSheet.CheckBoxes(Application.Caller).Value = xlOn Then
    ActiveSheet.Range("A70:H74").UnMerge
    ActiveSheet.Range("A70").Value = "Enter Multiple GCIF below and Select appropriate Doc Type from drop down list"
    ActiveSheet.Range("A71").Value = "Financial Statement - Annual"
    ActiveSheet.Range("B70:H70").Value = "Select Doc Type from drop down list"
    ActiveSheet.Range("B71:H74").Validation.Add xlValidateList, , , "=$N$2:$N$99"
    Else
    ActiveSheet.Range("A70:H74").Value = Null
    ActiveSheet.Range("A70:H74").Merge (True)
    ActiveSheet.Range("A70").Value = "Comments"
    End If
    ActiveSheet.Range("A70:H74").Locked = False
    ActiveSheet.Protect PassVar, True, True, True
    End Sub

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Runtime Error 1004 Question

    Armored Wing,

    In the future please use Code tags (and not Quote tags) to surround code (see Forum Rules link in my sig for how).
    As to your question, its becuase you're trying to overwrite existing data validation without clearing the old stuff. Added a .Delete line to your code, give it a try:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

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