+ Reply to Thread
Results 1 to 5 of 5

VBA Module Run on Change "Method 'Value' of object 'Range' failed"

  1. #1
    Registered User
    Join Date
    09-28-2021
    Location
    Madison WI
    MS-Off Ver
    10
    Posts
    6

    VBA Module Run on Change "Method 'Value' of object 'Range' failed"

    Hi everyone,

    I am a newbie with VBA here and only started a few days ago. I am trying to recreate a version of customer manager app from Excel For Freelancers
    I was able to get the Macro run and load the data. However, when I try to code in the run macro when Sheet 1 change, I received an error message "Method 'Value' of object 'Range' failed". Could our experts here let me know where I went wrong? I attached a sample workbook as well. Thank you in advance for everyone's help!

    Below is the module I was able to run manual until the worksheet change

    Please Login or Register  to view this content.
    Worksheet Change:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by datanalyst1; 09-29-2021 at 10:14 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,117

    Re: VBA Module Run on Change "Method 'Value' of object 'Range' failed"

    When you use Change event code to change the cell(s), you need to set EnableEvents property to False/True in order to avoid unnecessary action.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-28-2021
    Location
    Madison WI
    MS-Off Ver
    10
    Posts
    6

    Re: VBA Module Run on Change "Method 'Value' of object 'Range' failed"

    Thank you very much jindon! The Application.EnableEvents works like magic.

    I have a follow up question to this. So do you have any advice for newbie like me on how to know what property to add (like in the Change event code to add EnableEvents property)? In the tutorial I followed, the person didn't have EnableEvents and he was able to have the code run. Just want to learn from your experience how to spot missing property or like know best practices? Thank you again for your time!

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,117

    Re: VBA Module Run on Change "Method 'Value' of object 'Range' failed"

    Quote Originally Posted by datanalyst1 View Post
    In the tutorial I followed, the person didn't have EnableEvents and he was able to have the code run.
    The same code?

    If the code doesn't change any cell in the sheet in which the code is written, no need to touch EnableEvents property.
    But if the code changes any cell (like your case), Change event will run each time it changes the cell, that means if the code changes 100 cells, it runs 100 times more.

    Anyway EnableEvents property is the first to know in the Sheet Event code to avoid unnecessary operation...

  5. #5
    Registered User
    Join Date
    09-28-2021
    Location
    Madison WI
    MS-Off Ver
    10
    Posts
    6

    Re: VBA Module Run on Change "Method 'Value' of object 'Range' failed"

    Quote Originally Posted by jindon View Post
    The same code?

    Change event will run each time it changes the cell, that means if the code changes 100 cells, it runs 100 times more.
    Yes somewhat same code and it changes cells in the sheet as well so I am not sure why. But your explanation makes a lot of sense and now I understand the reason behind EnableEvents. Thank you!!

    The video I follow called "Learn How To Become An Excel Developer As I Create This Customer Manager In Excel From Scratch" - Minute 51:28 just as a reference for the code i talked about above
    Last edited by datanalyst1; 09-29-2021 at 10:19 AM.

+ 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. [SOLVED] "Method 'Range' of object '_Worksheet' failed" error message
    By Simply_Me in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-07-2021, 03:02 AM
  2. [SOLVED] "Method 'Range' of object '_worksheet' failed" when a different sheet is active
    By CO# in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2014, 11:48 AM
  3. [SOLVED] Receiving a "Method 'Range' of object'_Global' failed" error
    By aloha31 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-17-2013, 06:51 PM
  4. XL03 Sort error: "Method 'Range' of object '_Worksheet' failed"
    By AdLoki in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2011, 08:23 AM
  5. Error: "Method 'Range' of object '_Global' failed"
    By dblword in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-26-2009, 05:15 PM
  6. [SOLVED] Excel-VBA: "1004 - Method 'Range' of object '_Global' failed"
    By THA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2005, 05:06 AM
  7. [SOLVED] "GoalSeek method of Range object failed" error message
    By Fixit_Steve in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-13-2005, 04:06 PM

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