Consulting

Results 1 to 10 of 10

Thread: Grocery lists

  1. #1

    Grocery lists

    I have two grocery lists (in 2 columns) and have captured these in two arrays.
    However, there are some items in the lists that appear in both list 1 and list 2.
    How do I get the items that are in both lists seperated, maybe even copy and paste them on the sheet?
    Is this possible?

    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What exactly do you want to do with the duplicates? The answer will affect the suggested solution.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Transfer the duplicates to another column on the same sheet if that's possible

  4. #4
    by transfer I mean copy and paste, not cut existing data

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You could add a formula in another column like so

    =COUNTIF(B:B,A2)

    copy down and autofilter the new column for values > 1, then copy the visble cells in column A.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Sorry if for being too vague, will try to be more specific.
    what I am hoping to achieve is have 3 arrays at the end of the sub. So array 1 would be the items in list 1 only, array 2 would be the items in list 2 only and array 3 would be the duplicates, i then want to show the 3 arrays in 2 columns beside the 2 lists.

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    so you basically want a list of the duplicates as you already have the first two lists, right?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    I have an array with the two full lists, but not sure how to get 3 arrays with the two lists exluding the duplicates and and one with the duplicates.
    I want to use arrays for this problem.

  9. #9
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    You keep talking about arrays.....how about posting some code....I'm confused.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  10. #10
    You could use the find method to search for matches:

    You would have the values in your first grocery list in B3:b10 and the 2nd list in C3:C20 and any matching items would go into column D:

    You could search through the 2nd list with the items in your first list. Everytime you find a match you could add that item to your list in column D

    You can look up the Find Method in the Excel Macro help for more information on how to use the method.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •