+ Reply to Thread
Results 1 to 16 of 16

Macro that searches through column and removes specific duplicates

  1. #1
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    How to search down a column for specific criteria

    Hello, I have a really long list of names when people contacted my company, with their date of contact in the column next to it. I would like to be able to identify if the previous month was the first time someone contacted my company. So I need a formula (or macro) that would search the names column for duplicates and if the duplicate's date is outside of a specified range it will delete all instances. So I would be left with only the people that contacted us for the first time in that range. Thanks for your help in advance!

  2. #2
    Registered User
    Join Date
    12-27-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: How to search down a column for specific criteria

    Why not just filter the rows by date with the Unique Records Only option?

    http://office.microsoft.com/en-us/ex...010073943.aspx

    Would it be better to filter by a unique ID, such as a phone number, rather than a name to make sure you do not exclude any contacts with similar names?

  3. #3
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: How to search down a column for specific criteria

    I might not be following you-
    I only have access to the names and the date called.. but the caller can not get credit for calling if they have called before the specified date range ( if im running the report for april 2013, and they called in january, i want them to be deleted - all times they called - so im left with just a list those that called for the first time in april). I was filtering down to the date range, highlighting those that called, and then sorting by name to check and see if they had called previously, but with the length of the list this is too time consuming.

    If the person called twice in april, and not called before april, they should get credit for calling once. Hopefully I can understand the formula(or macro) enough to change that in case i need to count them twice for april *not all my reports are 1 call reports- sometimes they get up to 3 credits for the given month*
    Last edited by bruizer31; 05-15-2013 at 12:42 PM.

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,876

    Re: Macro that searches through column and removes specific duplicates

    Please attach a Sample Workbook!!

    Thank You,

    Deep
    Cheers!
    Deep Dave

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro that searches through column and removes specific duplicates

    if it's alway whole monts you can use an helpcolum to define the month an also define if the value is duplicated.

    After that you can simple filter on that columns.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  6. #6
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Macro that searches through column and removes specific duplicates

    Is your data already sorted by date??
    Gary's Student

  7. #7
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: Macro that searches through column and removes specific duplicates

    Yes, sorted by date Newest to Oldest

  8. #8
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: Macro that searches through column and removes specific duplicates

    Capture111.PNG

    In this example everyone but August Olesch should be deleted.. The incentive would be from 1/1/2011-present, so thats what my report will return. All the others called before May, including Barbara Schell, so she wouldnt get credit for being a first time caller in May. I sorted by name just to show the list in a single screen, it is normally sorted by date- newest to oldest

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,679

    Re: Macro to remove duplicate callers

    With the list sorted ascending by date, add a formula in C2 and copy down:

    =COUNTIF(A$1:A2, A2)

    AutoFilter col B for April and col C for 1
    Last edited by shg; 05-16-2013 at 12:17 PM.
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: Macro to remove duplicate callers

    Quote Originally Posted by shg View Post
    With the list sorted ascending by date, add a formula in C2 and copy down:

    =COUNTIF(A$1:A2, A2)

    AutoFilter col B for April and col C for 1
    Thank you! How could i turn this into a macro so it will do all that for me, so i would just be left with the few rows that are the results? I'm at a new job and would like to impress my department with a new macro for everyone to use! -Thanks!

  11. #11
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: Macro to remove duplicate callers

    Quote Originally Posted by shg View Post
    With the list sorted ascending by date, add a formula in C2 and copy down:

    =COUNTIF(A$1:A2, A2)

    AutoFilter col B for April and col C for 1
    Would it also be possible to add to the macro how many calls each person gets? Sometimes a company will run an incentive where the first 2 calls get the incentive as opposed to just the first call during the program. I would still need to report on that monthly.

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,679

    Re: Macro to remove duplicate callers

    How could i turn this into a macro so it will do all that for me
    Try recording one.

    Would it also be possible to add to the macro how many calls each person gets? Sometimes a company will run an incentive where the first 2 calls get the incentive as opposed to just the first call during the program.
    Filter for 1 and 2 instead of just 2.

  13. #13
    Forum Contributor
    Join Date
    12-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    232

    Re: Turn this into a macro?

    create a sample sheet of the data and use dummy info, with expexted results. Your two columns of data is pointless.

  14. #14
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: need a macro to filter for specific data

    The only thing I didn't understand was your comment at the very end, about asking you how many times "a person can be counted."

    Otherwise, your instructions seemed quite clear.

    Here's my take on a solution. This modified example seems to do what you wish.

    (Rather than delete data from the main list, instead I simply listed the employees who will receive a gift card on a different tab.)

    callers by month - modified.xlsm

    Modify the code as you see fit.

  15. #15
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: need a macro to filter for specific data

    Quote Originally Posted by Ed_Collins View Post
    The only thing I didn't understand was your comment at the very end, about asking you how many times "a person can be counted."

    Otherwise, your instructions seemed quite clear.

    Here's my take on a solution. This modified example seems to do what you wish.

    (Rather than delete data from the main list, instead I simply listed the employees who will receive a gift card on a different tab.)

    Attachment 236311

    Modify the code as you see fit.
    Thanks. Ill take a look! Sorry for the confusion. Some incentive programs say the first two calls a person makes get counted as opposed to just the very first time they call us. So regardless of what month they call during the program they still count whenever the first two calls were.

    Thanks for your help!

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro that searches through column and removes specific duplicates

    thebkap,

    You had created about 4-5 threads for the same question. This is completely against forum rule 5. All your threads have been merged. Please do not create duplicate threads in future.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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