+ Reply to Thread
Results 1 to 9 of 9

run time error method value of object range failed

  1. #1
    Registered User
    Join Date
    05-18-2015
    Location
    paris
    MS-Off Ver
    2010
    Posts
    16

    run time error method value of object range failed

    i'm having a macro runing depending on the value of the cell I1, every time the value in I1 changes, i want the correponded dependent cell values change, there is one case that i want to clear the contents of certain range but in this case the code happens to run into an infinite loop and i have no idea why here is my code, hope someone could help! thanks all in advance!

    Please Login or Register  to view this content.
    Last edited by gloger; 07-27-2015 at 04:57 AM.

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: run time error method value of object range failed

    Firstly, your title and the description of the issue doesn't seem to match. So are you experiencing a runtime error or an infinite loop?

    Secondly, for some unknown reason, it seems you have edited your code to look the way it is. However, it seems that your code is actually a Worksheet Change event. As such, when the macro you wrote changes something within the sheet "Range.Value" or "Range.ClearContents" it will trigger the Change event macro again. Causing the infinite loop. As far as I know, Excel has a built in safe-guard against these kinds of infinite loop, so I'm not sure why you are having it. In any case, to prevent it, you'd need to disable EnableEvents before your code makes any changes to the model. Example...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-18-2015
    Location
    paris
    MS-Off Ver
    2010
    Posts
    16

    Re: run time error method value of object range failed

    please excuse my bad description
    run time error is the bug that comes with the macro, i said infinite loop because it seems that the program couldn't stop and the screen is blinking

    here is the original code and i was using worksheet calcuate actually.. however, this code is not working automaticammy like yesterday when i first tested it:::so werid;.
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: run time error method value of object range failed

    When exactly do you want this code to run?

    The first code you posted would need to be run manually, and the second code you posted would run whenever the sheet calculated.

    As for the run-time error, I can't replicate that.

    Is the sheet protected?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    05-18-2015
    Location
    paris
    MS-Off Ver
    2010
    Posts
    16

    Re: run time error method value of object range failed

    i want it to run whenever the value in cell I1 changes,
    the sheet is not protected

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: run time error method value of object range failed

    Does this code, which belongs in a worksheet module, work?
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-18-2015
    Location
    paris
    MS-Off Ver
    2010
    Posts
    16

    Re: run time error method value of object range failed

    no it is not working at all..

    no actually it worked with a new sheet i just created but not the previous one and i dont know why...

    ok. the thing is that , cell I1 is actually a formula and its value changes by its formua, but if i change I1 manually, then your code works just perfectly
    Last edited by gloger; 07-24-2015 at 09:22 AM.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: run time error method value of object range failed

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

  9. #9
    Registered User
    Join Date
    05-18-2015
    Location
    paris
    MS-Off Ver
    2010
    Posts
    16

    Re: run time error method value of object range failed

    thank you Norie, the problem is solved, i copied the sheet contents little by little and found there was a mistake inside a table, i don't know that the mistake is, but i recreated the table and then the code worked fine.

+ 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. Run time Error 1004 Method 'Range' object '_Worksheet 'failed
    By Monica1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2013, 07:42 AM
  2. [SOLVED] Run-time error ‘1004’: Method ‘Range’ of ‘object’_Global’ failed.
    By dhiresh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2013, 12:04 PM
  3. Help! Why am I getting Run-time error '1004': Method 'Range' of object'_Gloabl' Failed
    By ExcelNewbeee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2012, 05:35 PM
  4. [SOLVED] Run time error 1004: method range of object _global failed
    By Danry in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2012, 07:31 PM
  5. Run-time error '1004'. Method 'Range' of object '_Global' failed
    By mjj347 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-24-2012, 11:09 AM
  6. Run-Time Error 1004 Method Range of object _Global Failed?
    By MadDino in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-11-2011, 05:13 AM
  7. Replies: 4
    Last Post: 01-05-2011, 06:37 PM
  8. Run time error 1004 - Method 'Range' of 'Object'_Global' failed
    By excelaspire0219 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-10-2009, 01:18 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