+ Reply to Thread
Results 1 to 5 of 5

Worksheet Change Event Causing Runtime Error 9

  1. #1
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Worksheet Change Event Causing Runtime Error 9

    Hi All,

    I've created a little workbook to keep track of my to-do list (see attached). I have a data validation list in column A, and I use the following code to move lines from one worksheet to another when I change the value in column A:


    Please Login or Register  to view this content.

    It works when I change the value and then run the macro manually. But when I try to use a worksheet change event to automate the process, I keep getting run-time errors because of the bold line above. I've tried calling the macro from the change event, and I've tried putting the code directly into the change event. Same each time.


    Please Login or Register  to view this content.

    Any idea how to fix this?
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Worksheet Change Event Causing Runtime Error 9

    I'm not sure if I understood correctly what you want to do but try this macro. Place the macro in the worksheet code module for each sheet (not in DataVal). Make your selection in column A.
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: Worksheet Change Event Causing Runtime Error 9

    Mumps, that's a really elegant solution!

    It works even better than doing it my way. Thanks so much!!!

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Worksheet Change Event Causing Runtime Error 9

    You are very welcome.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Worksheet Change Event Causing Runtime Error 9

    Try fully qualifying the c address with the sheet name. i.e.

    Please Login or Register  to view this content.
    change Sheet1 to be whatever your vba sheet code name is. NB that's the VB code name not the Sheet tab name.

    Incidentally lr isn't dimmed which implies you don't use Option Explicit to force variable declaration which is always a good idea.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ 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. How to tell What action is causing an on event Workbook change
    By Steveapa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-01-2015, 03:56 PM
  2. Need to add if error code to worksheet change event to stop a run-time error
    By KT99 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2014, 03:10 PM
  3. PasteSpecial causing RunTime error 1004 & autofill doesn't stop at last line
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-24-2014, 09:18 AM
  4. [SOLVED] Application.Calculate or F9 causing runtime / Visual Basic error
    By baldmosher in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-20-2013, 05:26 AM
  5. Application.Calculate causing Runtime Error
    By quekbc in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-20-2013, 05:14 AM
  6. runtime error, isempty, worksheet change event
    By Code Flunkie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2011, 05:17 PM
  7. [SOLVED] Essbase Causing Selection Change Event to Fire
    By Jim Thomlinson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2005, 05:45 PM

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