+ Reply to Thread
Results 1 to 4 of 4

.DataBodyRange issue - Sorting loop suddenly stops with no errors

  1. #1
    Registered User
    Join Date
    07-29-2020
    Location
    Kansas, USA
    MS-Off Ver
    Up-To-Date
    Posts
    3

    Question .DataBodyRange issue - Sorting loop suddenly stops with no errors

    I have some code that is supposed to move data from one table to another while sorting them. So a row is added to Table2 and it's supposed to look for another row that meets the criteria and then add that row. It runs and just stops without error halfway through. I noticed the last row it usually stops on usually contains the header info from table1. But I can't figure out how to implement ".DataBodyRange" to prevent this.

    The full code:
    I will also attach what I'm working on for visual reference.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: .DataBodyRange issue - Sorting loop suddenly stops with no errors

    Hi there,

    Your logic is quite difficult to follow.

    Please Login or Register  to view this content.
    should this read:

    Please Login or Register  to view this content.

    Also:

    Please Login or Register  to view this content.
    lastRowTbl2 is defined at the start of the routine and does not increase as rows are added to the table - is this intentional?


    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    07-29-2020
    Location
    Kansas, USA
    MS-Off Ver
    Up-To-Date
    Posts
    3
    Quote Originally Posted by Greg M View Post
    Hi there,

    Your logic is quite difficult to follow.

    Please Login or Register  to view this content.
    should this read:

    Please Login or Register  to view this content.

    Also:

    Please Login or Register  to view this content.
    lastRowTbl2 is defined at the start of the routine and does not increase as rows are added to the table - is this intentional?


    Regards,

    Greg M

    Yeah, I'll admit coming back to VBA after VB & C# is not like riding a bicycle.

    The goal is to put a row from table1 into table2, then find a row from table1 where each column from E through AU has to remain under 30.06 when added together. If it goes over it'll skip to the next. When it finds one it'll insert it into table2. Then it will look for a row in table1 that compares to only the last inserted row in table2 2.

    The purpose is columns E through AU are actually times, and I am wanting to prevent putting two units (rows) on the assembly line that will go over 30.06 minutes in any station (columns). Those that will cause this will be identified and the manufacturing process will be evaluated.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: .DataBodyRange issue - Sorting loop suddenly stops with no errors

    Hi there,

    Let's see if I've understood your requirements correctly.

    Take a look at the attached version of your workbook and see if it does what you need. It uses the following code:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

+ 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. Array formula suddenly stops working
    By sunboy in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 07-29-2020, 11:34 AM
  2. Outlook Forwarding Script Errors Out and Stops Rule
    By dipique in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 11-14-2013, 03:46 PM
  3. [SOLVED] SUMIFS suddenly returns zero values/stops working for 2013 date ranges
    By KShuff in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-07-2013, 03:53 PM
  4. Replies: 4
    Last Post: 01-31-2013, 06:58 PM
  5. Excel suddenly starts to give compile errors
    By Peter Griffin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2012, 01:17 PM
  6. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  7. Macro suddenly stops working
    By Ahoette01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-02-2010, 05:58 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