+ Reply to Thread
Results 1 to 9 of 9

Create a list of duplicated numbers in a worksheet

  1. #1
    Registered User
    Join Date
    04-27-2007
    Location
    Lancaster UK
    Posts
    37

    Create a list of duplicated numbers in a worksheet

    Hi all, we are a mail order business and when we send out catalogues to people, we inevitably get some returned to us as undeliverable/moved/incorrect address etc. When this happens, we input the customer number onto an excel sheet (see attached).

    When there is two entries for a customer number, we need that customer number to show on a list (preferably on a different worksheet) so that we can see who has had two or more 'fails' and stop sending catalogues to that customer.

    I hope you can help,

    Thanks in advance,

    Steve Quinn
    Woods Online
    www.woods-online.co.uk
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    See the attached file where I added macro 'Macro1'.

    I hope it's what you need.

    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-27-2007
    Location
    Lancaster UK
    Posts
    37

    20 minutes = Awesome

    Nice one Antonio, we are very grateful for your help - it works perfectly.

    Regards,

    Steve Quinn
    Woods Online
    www.woods-online.co.uk

  4. #4
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    Hi Steve,

    My below Conditional Formatting suggestion is not a complete answer (esp when compared to Antonio's) but it could be used in conjunction with Antonio's macro to provide a visual warning that the customer number is used twice.

    1) select a region of cells that includes all your entries so far & the number of cells that you expect to use in the near future (not the entire worksheet though as the next step may slow /freeze your computer).

    2)Open Conditional Formatting eg [alt + O + D], change the dropdown box to formula is & type the following (excluding the quotation marks) into the box on the right:
    "=countif($a$1:$r$200,a1)>1"
    where
    $a$1:$r$200 can be changed to the range you want and
    a1 is the address of the cell that is currently active.

    3) Click format & choose an option that will catch the eye eg a red or orange background under the Pattern tab.

    4) click ok until back at the normal excel window.


    If using Antonio's macro approach I would add the below lines of code in just before the end of the macro to "free memory" (for any variables that have been "set") when the macro finishes ie...
    Please Login or Register  to view this content.
    and I would also add
    Please Login or Register  to view this content.
    but I'm not a 100% sure on this one because I'm not really sure on the impact on created objects or "scripting" code.


    Antonio,
    I'm curious, why don't you have option explicit at the top of your code to force the variable declarations?
    Would this mess up the "myarray" somehow/would it be declared as a string?


    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  5. #5
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    Here's another attached file to follow broro183's suggestions.

    In thi smacro I avoid to use scripting objects and added instructions to free memeory.

    Regards,
    Antonio
    Attached Files Attached Files
    Last edited by antoka05; 09-13-2007 at 03:44 PM.

  6. #6
    Registered User
    Join Date
    04-27-2007
    Location
    Lancaster UK
    Posts
    37

    Your all very kind - I now have another question :-)

    Hi all again, i have a further requirement with this worksheet (well, two actually but i will save the second one for a different post!)

    Ok, once this sheet shows me who has had two failed deliverys, i remove those people from our mailout list.

    I then need to delete the two entries from the first sheet, so that next time we input some nondelivereds and run the first macro, we get people who have not been taken off the list yet.

    For your info, i have tried to do this a few ways without deleting the matched pairs, but, for example, if you add a new nondelivered to the list, and run the original macro, the new matched pair entry on sheet2 can appear in random places within the list so I cannot rely on a premise of say 'i have done up to row 74 so any new ones must be after that'

    I also tried marking each entry on sheet2 with an x in the next column to show it had already been dealt with but on running the first macro again the x's dissapear.

    Obviously if anyone can think of a better way to do this we are very grateful for your help.

    Thanks in advance,

  7. #7
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    See attached file.

    You don't need to delete old customers because now macro will add new double customers Id at the bottom of sheet2 and will select new added customers with yellow backcolor.
    In column 'B' of sheet2 I added also date/time (if you don't like dd/mm/yyyy format please change the 'format' instruction in macro1) so you can remember when you noticed that double customer Id.

    Regards,
    Antonio
    Attached Files Attached Files
    Last edited by antoka05; 09-17-2007 at 03:11 AM.

  8. #8
    Registered User
    Join Date
    04-27-2007
    Location
    Lancaster UK
    Posts
    37

    excellent - thanks a lot

    Hi there, thanks very much for this solution which seems to be fine and suits our needs perfectly.

    Steve

  9. #9
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    Glad to know it helped.

    Regards,
    Antonio

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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