+ Reply to Thread
Results 1 to 8 of 8

Duplicates-Replace adjacent cell with lowest value

  1. #1
    Registered User
    Join Date
    09-27-2018
    Location
    Ohio
    MS-Off Ver
    19
    Posts
    21

    Duplicates-Replace adjacent cell with lowest value

    Hello All!

    Example workbook attached.

    I need to write a vba script that finds the duplicates in column A, then copies the lowest value in column E to each duplicate.

    For example, there are two of Brandy but with two different dates in E (8/21/2013 and 8/21/2010). I need E in each row that has Brandy in column A to show 8/21/2010. Same scenario with CJ, but CJ needs to show 1/6/2010 in each row.

    Any thoughts on how to do this?

    Thanks a bunch!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Duplicates-Replace adjacent cell with lowest value

    Hi there,

    Try this (though initially on a copy of your data as the results cannot be undone of they're not as expected):

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Duplicates-Replace adjacent cell with lowest value

    Add Headings Row for another option...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 07-22-2020 at 04:28 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Duplicates-Replace adjacent cell with lowest value

    much easier...
    For 2019, 365
    Please Login or Register  to view this content.
    Or if 2016 or earlier, then
    Please Login or Register  to view this content.
    Last edited by jindon; 07-22-2020 at 05:55 AM.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Duplicates-Replace adjacent cell with lowest value

    @ jindon

    Think Op wants...
    finds the duplicates in column A, then copies the lowest value in column E to each duplicate.
    Lowest date of found duplicate Column E of each duplicate...

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Duplicates-Replace adjacent cell with lowest value

    Updated my code in post #4.

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Duplicates-Replace adjacent cell with lowest value

    Will MINIFS work in OP version...
    Does not work with my 2010,2013,2016

  8. #8
    Registered User
    Join Date
    09-27-2018
    Location
    Ohio
    MS-Off Ver
    19
    Posts
    21

    Re: Duplicates-Replace adjacent cell with lowest value

    Quote Originally Posted by Trebor76 View Post
    Hi there,

    Try this (though initially on a copy of your data as the results cannot be undone of they're not as expected):

    Please Login or Register  to view this content.
    Regards,

    Robert
    This worked perfectly! Thank you!

    Quote Originally Posted by sintek View Post
    Add Headings Row for another option...
    Please Login or Register  to view this content.
    Appreciate the reply, I did not try your code because the data set I am working with doesnt have headers. Yes it would be easy enough to add them either manually or vba but for the sake of not adding anything extra...

    Quote Originally Posted by jindon View Post
    much easier...
    For 2019, 365
    Please Login or Register  to view this content.
    Or if 2016 or earlier, then
    Please Login or Register  to view this content.
    Your code for 2019 (of which I have) worked perfectly as well! Lot less to type thats for sure! Thank you!

    Quote Originally Posted by sintek View Post
    Will MINIFS work in OP version...
    Does not work with my 2010,2013,2016
    Not sure how it would work on other versions. I do need to make this compatible with earlier versions though, so I might have a backup copy with Trebor76's code.

    Just some back story on this project, I have 11 retail locations and pay vacation time to all my employees after one year of service regardless of if they are part time or full time. The vacation time I pay is based upon average hours per week worked in the last six months. Some of my employees work in multiple locations all the time, some volunteer to help out at another locations for a week or two or three if need be. I was able to write code that removes duplicates and adds up hours from all locations for each employee. Problem was when I applied the filter for one year of service. Each location's "start" date doesn't sync across the master data file, so if in the last 3 months an employee pulled doubles to help out a different location, their "start" date would have kicked them out of a certain location when it comes to the calculations.

    This code inserted before the already written code will give an accurate average for all.

    Thank you all so much for your time and assistance!

    EDIT: I know my code is dirty, probably really dirty..it was a hack job mash up. Being an eleven store pizza guy and trying to learn vba, wheres the time.... I've made a few scripts that really make my life a lot easier, one click rather than twenty minutes. Wish I could learn more about how each one works though. If any of you would be willing to explain line by line what is happening in the above I would be very grateful. Not a request by any means, but if you feel like it, I am all ears Otherwise i will google everything above and try to make sense of it all.
    Last edited by pizzaguy4487; 07-22-2020 at 06:07 PM.

+ 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. Replies: 3
    Last Post: 07-21-2015, 05:10 PM
  2. Format the lowest valued cell without effecting duplicates
    By gomezth3killa in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-14-2015, 03:14 AM
  3. [SOLVED] Return the lowest value in a column BUT ONLY if adjacent cell has a value of "Y"
    By mstew in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-12-2015, 01:04 PM
  4. [SOLVED] remove duplicates based on adjacent cell value
    By kalelrojin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2015, 05:07 PM
  5. Find and replace with adjacent cell value.
    By james252 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-12-2014, 03:56 AM
  6. Adjacent cell reference - avoiding duplicates
    By ricdik in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-25-2013, 06:45 PM
  7. Find, Replace with and then replace adjacent cell
    By Craig2097 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2009, 12:42 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