+ Reply to Thread
Results 1 to 8 of 8

Modifying named range fails inside macro but succeeds when continued

  1. #1
    Registered User
    Join Date
    02-11-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    Excel 2010
    Posts
    12

    Modifying named range fails inside macro but succeeds when continued

    I got a macro that is gathering rows within named range:

    Please Login or Register  to view this content.
    sh is a Worksheet and r is a Range and NamedRangeExists is


    Please Login or Register  to view this content.
    I do not know why but it stopped running smoothly after some time/modifications to the code. Now when second row is added to the range (bold line) it fails with error 1004 ("formula contains an error" however all addresses returned are fine). What is strange is that it runs fine when I force to continue the macro. Any idea what is going on?
    Last edited by krzcho; 02-13-2012 at 04:59 PM.

  2. #2
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Modifying named range fails inside macro but succeeds when continued

    hello,

    I change a bit try below code, I hope it will be work for you
    Please Login or Register  to view this content.
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to rate it. To thank someone who has helped you, click on the star icon below their name.
    - This way you will add him some reputation points ... thanks in advance.

  3. #3
    Registered User
    Join Date
    02-11-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Modifying named range fails inside macro but succeeds when continued

    Your code works when I try it or even slightly modify to my situation (where range consists of entire rows and some of them are added to the named range in a loop) but my code still produces this strange error (which disappears when rerun/continued in break mode).
    I could send you the file I have but my office version is 2010 so I am not sure you will be able to repeat it?
    Last edited by krzcho; 02-11-2012 at 05:58 PM.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Modifying named range fails inside macro but succeeds when continued

    Hi krzcho
    This would be your best bet
    I could send you the file
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    02-11-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Modifying named range fails inside macro but succeeds when continued

    Here it is: https://docs.google.com/open?id=0B8P...M1NmQyZDNjZTM5
    Please use "Update the template" link or "UpdateWorkbook" macro
    When error happens press debug and F5 and you will see that error no longer appears (but be aware that this macro is run on three worksheets so it will happen three times in a row)
    Thank all of you for any help in advance

  6. #6
    Registered User
    Join Date
    02-11-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    Excel 2010
    Posts
    12

    Angry Re: Modifying named range fails inside macro but succeeds when continued

    I got an idea not to recreate the range used to store rows but use some predefined reference as starting point

    Please Login or Register  to view this content.
    but now I got another strange situation:

    Please Login or Register  to view this content.
    and the input is

    Please Login or Register  to view this content.
    WTF???

  7. #7
    Registered User
    Join Date
    02-11-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Modifying named range fails inside macro but succeeds when continued

    =$1:$1 did the trick but error is still there...
    manually making address instead of using Union does not help...
    Office looks patched...
    Finally I have found it!
    http://social.msdn.microsoft.com/For...1-c17d957cbb5c
    http://www.jkp-ads.com/Articles/ExcelNames10.asp
    One day behind

    Question is: whether it is me who does not understand RefersTo requirements on is it a bug in Excel?
    http://msdn.microsoft.com/en-us/library/ff835300.aspx
    defines RefersTo as "Describes what the name refers to, in English, using A1-style notation"; does English defines list delimeter? I always though that macros work with "," separator only while my code now works only if i replace address delimiter from "," to my local one (";")?

    It looks like it worked in break mode as excel was switching from system language to plain english. Weird.


    Please Login or Register  to view this content.
    Last edited by krzcho; 02-13-2012 at 05:11 PM.

  8. #8
    Registered User
    Join Date
    02-11-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Modifying named range fails inside macro but succeeds when continued

    Strange think again. Today refersToLocal does not work. Now I got

    Please Login or Register  to view this content.
    Excel has problems with locale when using RefersTo/RefersToLocal

+ 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