+ Reply to Thread
Results 1 to 9 of 9

macro crashes and will not restart if value not found is added

  1. #1
    Registered User
    Join Date
    09-22-2016
    Location
    England
    MS-Off Ver
    2013
    Posts
    14

    macro crashes and will not restart if value not found is added

    Hello

    I am having an issue where the following code comes to an error code rather than completing the sub if a value is added that cannot be found in column 2.
    the issue looks like it is coming from the move.select on line 11, but without this line the if function that decides whether or not to add a line does not work.


    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: macro crashes and will not restart if value not found is added

    Hi, the beginning of your code should look like
    Please Login or Register  to view this content.
    Regards.
    Last edited by maras_mak; 11-29-2018 at 12:45 PM.

  3. #3
    Registered User
    Join Date
    09-22-2016
    Location
    England
    MS-Off Ver
    2013
    Posts
    14

    Re: macro crashes and will not restart if value not found is added

    Hello, sorry I might be missing the point but I do not see how this fixes my issue. with your proposed solution It gets rid of the full value meaning that the if function does not function at all.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: macro crashes and will not restart if value not found is added

    Change:

    Please Login or Register  to view this content.
    to:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  5. #5
    Registered User
    Join Date
    09-22-2016
    Location
    England
    MS-Off Ver
    2013
    Posts
    14

    Re: macro crashes and will not restart if value not found is added

    I tried the formula you suggested but it now has the same issue as if I did not have the move.select in that it will only run the insert line portion of the code and will not react correctly if the cell is blank

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: macro crashes and will not restart if value not found is added

    1. Do not use "move" as a variable name, it's vba language word (method).
    2. And how about this(?):
    Please Login or Register  to view this content.
    Last edited by mjr veverka; 11-30-2018 at 09:49 AM. Reason: adding "Application.EnableEvents = False/True"

  7. #7
    Registered User
    Join Date
    09-22-2016
    Location
    England
    MS-Off Ver
    2013
    Posts
    14

    Re: macro crashes and will not restart if value not found is added

    Thank you so much, this worked brilliantly, I didn't know move was a variable, I am relatively new to VBA

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: macro crashes and will not restart if value not found is added

    Thanks for the rep!

  9. #9
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: macro crashes and will not restart if value not found is added

    Quote Originally Posted by BaronVonBeefDip View Post
    ... I didn't know move was a variable, I am relatively new to VBA
    ... "you learn something new every day" ...

    I have recently noticed that the frequently used variable name "rng/Rng" (for some range (-s): Dim rng As Range, Dim Rng As Range, etc.), is in fact the property name of the "Sort" object (Sort.Rng property) ... "many of us" make this "mistake".
    ... so, "everybody learn something new every day" ... and ... so be it ...

+ 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. Macro: Help, Need Macro, Change Color, Open File, Restart at date
    By fastfire in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2013, 05:52 PM
  2. issues with shared workbook how to pause macro and restart macro
    By sspreyer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2013, 11:01 AM
  3. Excel 2007 crashes when chart title is added
    By Astroverted in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 05-02-2013, 06:31 PM
  4. Stop Macro, Select Cell, Restart Macro
    By tenk283 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2010, 12:48 AM
  5. Using IF to restart macro when cell is a particular value
    By Carlsbergen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-19-2010, 09:29 AM
  6. Stop and restart macro(s) programatically
    By JP Romano in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-20-2010, 11:44 PM
  7. Excel 2007 crashes when chart title is added-compatability mode
    By jaclayton in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-23-2008, 06:36 AM
  8. [SOLVED] Can I break and restart a link in a macro
    By tweacle in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-23-2005, 11:35 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