+ Reply to Thread
Results 1 to 9 of 9

Runtime 1004 driving me insane!

  1. #1
    Registered User
    Join Date
    02-10-2015
    Location
    Liverpool, England
    MS-Off Ver
    2010
    Posts
    5

    Runtime 1004 driving me insane!

    Long time member, first time posting a thread.
    I'm getting 1004 error: Application-defined or Object-defined error. I can't for the life of me figure out what's wrong. The debug is throwing up a line of code that is perfectly fine!? Hoping someone with a fresh pair of eyes and more know-how can shed some light?
    Getting the error when I click a command button. I've only started getting the error when I added some code to the sheets change function but as far as I can tell, it should all work.
    Please Login or Register  to view this content.
    For reference, he's the worksheet change code:
    Please Login or Register  to view this content.
    Any help or suggestions would be greatly appreciated!
    Thanks.

    Pritch

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Runtime 1004 driving me insane!

    When your code hits this line:

    Please Login or Register  to view this content.
    it runs the Worksheet_Change code, which reprotects the sheet, so the next line in the calling code can't alter another cell.
    Rory

  3. #3
    Registered User
    Join Date
    02-10-2015
    Location
    Liverpool, England
    MS-Off Ver
    2010
    Posts
    5

    Re: Runtime 1004 driving me insane!

    Thanks Rory, but i've got the unprotect line again in the Worksheet change? I'm confused haha
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-10-2015
    Location
    Liverpool, England
    MS-Off Ver
    2010
    Posts
    5

    Re: Runtime 1004 driving me insane!

    Nevermind, brain fart moment. Just realised what you mean haha. Thanks Rory.

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Runtime 1004 driving me insane!

    Out of interest, why are you unprotecting and reprotecting the sheet when it's already been changed at that point?

  6. #6
    Registered User
    Join Date
    02-10-2015
    Location
    Liverpool, England
    MS-Off Ver
    2010
    Posts
    5

    Re: Runtime 1004 driving me insane!

    Other colleagues will be using it so it needs to be protected so they don't break it. The code unhides rows allowing them to enter data in unlocked cells based on what they select in another cell.
    i.e, they select say "1" from a drop down which then unhides 1 row to allow them to enter an employee's name etc whilst the document is still protected so they can't amend any other cells.

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Runtime 1004 driving me insane!

    Do you need your button code to actually trigger the Change event code?

  8. #8
    Registered User
    Join Date
    02-10-2015
    Location
    Liverpool, England
    MS-Off Ver
    2010
    Posts
    5

    Re: Runtime 1004 driving me insane!

    No. But I need the Change event code to work after the button code has finished. Is there a way to do this?

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Runtime 1004 driving me insane!

    Yes - disable events at the start of the button code and re-enable at the end, just like you did in the Change event.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Please help, it's driving me insane!! - Image to Word
    By RBLearning in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2019, 09:40 AM
  2. [SOLVED] Index Match with 2 criteria driving me insane
    By AndyGW in forum Excel General
    Replies: 6
    Last Post: 05-06-2017, 01:03 PM
  3. This is driving me insane... please help.
    By ajoh00n in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-17-2015, 10:43 AM
  4. Phantom Breakpoints Driving me insane!
    By fred3 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-04-2014, 01:36 PM
  5. [SOLVED] Sum row until criteria is met (driving me insane!)
    By Mbarnes in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-18-2012, 10:10 AM
  6. Excel time formating driving me insane
    By White noise in forum Excel General
    Replies: 6
    Last Post: 12-09-2006, 09:15 PM
  7. Date&Time calculation driving me insane
    By jondyad1 in forum Excel General
    Replies: 1
    Last Post: 04-06-2005, 09:22 AM

Tags for this Thread

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