+ Reply to Thread
Results 1 to 2 of 2

For loop produces duplicate results

  1. #1
    Registered User
    Join Date
    01-19-2021
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    6

    For loop produces duplicate results

    So I convert a date range to week numbers. This is some sample data:

    +-----------+------------+------------+--------------------+
    | Name | From | To | ProjectDaysPerWeek |
    +-----------+------------+------------+--------------------+
    | Bob | 02/04/2021 | 20/04/2021 | 4 |
    | Jessie | 05/05/2021 | 05/06/2021 | 5 |
    | Lars | 15/06/2021 | 15/07/2021 | 3 |
    | Kathy | 12/05/2021 | 22/06/2021 | 5 |
    | Bob | 10/04/2021 | 16/04/2021 | 2 |
    | Lars | 22/06/2021 | 30/06/2021 | 4 |
    | Kim | 10/06/2021 | 30/06/2021 | 5 |
    | Bob | 18/06/2021 | 24/06/2021 | 2 |
    +-----------+------------+------------+--------------------+

    And for the names that come up more than once (such as for Bob's and for Lars') I would want to extract the ProjectDaysPerWeek per
    Please Login or Register  to view this content.
    . That's what I am trying with this code:

    Please Login or Register  to view this content.
    However, this produces duplicate results as you can see in the results here:


    +------+-----------+---------+------------+------------+-------+-------------+
    | Name | From Week | To Week | From Date | To Date | Value | Week Number |
    +------+-----------+---------+------------+------------+-------+-------------+
    | Bob | 14 | 17 | 02/04/2021 | 20/04/2021 | 4 | 14 |
    | Bob | 14 | 17 | 02/04/2021 | 20/04/2021 | 4 | 15 |
    | Bob | 14 | 17 | 02/04/2021 | 20/04/2021 | 4 | 16 |
    | Bob | 14 | 17 | 02/04/2021 | 20/04/2021 | 4 | 17 |
    | Bob | 14 | 17 | 02/04/2021 | 20/04/2021 | 4 | 14 |
    | Bob | 14 | 17 | 02/04/2021 | 20/04/2021 | 4 | 15 |
    | Bob | 14 | 17 | 02/04/2021 | 20/04/2021 | 4 | 16 |
    | Bob | 14 | 17 | 02/04/2021 | 20/04/2021 | 4 | 17 |
    | Lars | 25 | 29 | 15/06/2021 | 15/07/2021 | 3 | 25 |
    | Lars | 25 | 29 | 15/06/2021 | 15/07/2021 | 3 | 26 |
    | Lars | 25 | 29 | 15/06/2021 | 15/07/2021 | 3 | 27 |
    | Lars | 25 | 29 | 15/06/2021 | 15/07/2021 | 3 | 28 |
    | Lars | 25 | 29 | 15/06/2021 | 15/07/2021 | 3 | 29 |
    | Bob | 15 | 16 | 10/04/2021 | 16/04/2021 | 2 | 15 |
    | Bob | 15 | 16 | 10/04/2021 | 16/04/2021 | 2 | 16 |
    | Bob | 15 | 16 | 10/04/2021 | 16/04/2021 | 2 | 15 |
    | Bob | 15 | 16 | 10/04/2021 | 16/04/2021 | 2 | 16 |
    | Lars | 26 | 27 | 22/06/2021 | 30/06/2021 | 4 | 26 |
    | Lars | 26 | 27 | 22/06/2021 | 30/06/2021 | 4 | 27 |
    | Bob | 25 | 26 | 18/06/2021 | 24/06/2021 | 2 | 25 |
    | Bob | 25 | 26 | 18/06/2021 | 24/06/2021 | 2 | 26 |
    | Bob | 25 | 26 | 18/06/2021 | 24/06/2021 | 2 | 25 |
    | Bob | 25 | 26 | 18/06/2021 | 24/06/2021 | 2 | 26 |
    +------+-----------+---------+------------+------------+-------+-------------+

    Any help is appreciated.

  2. #2
    Registered User
    Join Date
    01-19-2021
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    6

    Re: For loop produces duplicate results

    Actually, I solved it by adding a new counter called 'Cntr' to the code and outputting that into a new column then deduplicating the values.
    Hopefully this helps someone in the future!

    Please Login or Register  to view this content.

+ 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] If vlookup produces N/A results then takes value from another col.
    By batexcel in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-14-2019, 08:17 AM
  2. Using ln() function produces strange results
    By OGAngryHulk in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-25-2018, 07:20 PM
  3. Conditional StDev Produces Erroneous Results
    By mjcarman01 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-15-2017, 09:20 PM
  4. [SOLVED] Offset - same formula produces different results
    By BRISBANEBOB in forum Excel General
    Replies: 4
    Last Post: 09-23-2016, 07:40 PM
  5. [SOLVED] Formula produces unexpected results
    By furface00 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-04-2014, 02:17 PM
  6. Same vba routine produces different results
    By john1674 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2013, 05:44 AM
  7. excel formula produces duplicate last names
    By johnmerlino in forum Excel General
    Replies: 5
    Last Post: 11-04-2010, 12:17 AM

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