+ Reply to Thread
Results 1 to 16 of 16

VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

  1. #1
    Registered User
    Join Date
    12-29-2012
    Location
    USA
    MS-Off Ver
    Office 2019
    Posts
    37

    VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Hello
    I have a workbook constructed of a consecutive 31 sheets each sheet represents a day of the month (January 1 , January 2 , ect )
    Each day has two ranges of cells with value entered in on a daily basis. Range 1 is (H32:H41) and range 2 is (W3:W17)
    -I was able to do a conditional format to compare between both ranges and find out duplicate values per each day.
    but I need help to find a way to find out duplicate values entered on any cell of both ranges for the entire workbook.

    Simply a warning prompt (if value was entered in January 5th already was entered on January 3rd)

    Thank you.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.


    Hello,

    you can try the VBA method Range.Find

  3. #3
    Registered User
    Join Date
    12-29-2012
    Location
    USA
    MS-Off Ver
    Office 2019
    Posts
    37

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Hello Marc
    Would be too much to ask for the complete code ?
    happy New Year

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    See next code
    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  5. #5
    Registered User
    Join Date
    12-29-2012
    Location
    USA
    MS-Off Ver
    Office 2019
    Posts
    37

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Thank you PCI , here is what i got
    i got this prompt Attachment 854077
    when i hit ok, it says Sheet 1 and sheet 2, hit ok again and goes on sheet 1 and sheet 3, and the loop goes on.
    and it freezes any tasks on the workbook.

    Thanks again for trying.
    Happy New year

  6. #6
    Registered User
    Join Date
    10-16-2023
    Location
    Poland
    MS-Off Ver
    Excel 2019 32bit WIN10
    Posts
    88

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    If I understood correctly, insert a macro like this into the ThisWorkbook module:

    Please Login or Register  to view this content.
    It will work automatically when you change the values ​​in the cells of the given ranges.

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Fatekb,
    What about a file ...!
    See attached my sample one.
    Happy new year to you to.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    In complement a few words to explain what the macro is doing.
    For each cells in in range H32:H41 it searches if exists a duplicate value with others H32:H41 range in all others sheets.
    Then it is doing the same for range W3:W17
    Then it is doing the same between range H32:H41 and range W3:W17 throw all sheets.

  9. #9
    Registered User
    Join Date
    12-29-2012
    Location
    USA
    MS-Off Ver
    Office 2019
    Posts
    37

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Hello
    Sorry PCI it took me some time to respond back to you, the only downside to this macro is I have to hit the okay button to loop and compare comparing each sheet throughout the entire workbook.
    the more I think about it, the more the conditional format way makes more sense to me and the way to go, but i hope Microsoft come up with a way that allow conditional format to work on the entire workbook than just a single sheet.

    Thank you

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Dear Fatekb
    Your specification was "Simply a warning prompt"
    What do you want, in case there is several times the issue to display: To color cells ?

  11. #11
    Registered User
    Join Date
    12-29-2012
    Location
    USA
    MS-Off Ver
    Office 2019
    Posts
    37

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Dear PCI
    yes, Color Cells is preferred. Currently each sheet is conditionally formatting to itself to monitor both ranges within that sheet.

    Thank you Again.

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    yes, Color Cells is preferred
    Ok but as far as there until 31 sheets it could be difficult afterwards to make the connection betwen duplicate cells, isn't it ?
    See next code

    Please Login or Register  to view this content.
    Last edited by PCI; 01-03-2024 at 11:01 AM.

  13. #13
    Registered User
    Join Date
    12-29-2012
    Location
    USA
    MS-Off Ver
    Office 2019
    Posts
    37

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Hello PCI
    It worked. but once I execute it for the first time, after that it will not recognize if there a duplicate value (Red color will not change from the cells on the remaining days that has duplicate value after the initial run).
    for example, if I ran it on the 15th of the month for the first time. and try to run it again on the 19th day the red color remains on the cell that contain duplicate values from the 16th thru the 31st sheets.
    and will also be very helpful at the end of the search if a pop-up message summarize which sheet names has duplicate value in those two ranges.
    and lastly which I did not mention can you have the macro to run for the first 31 sheets only. I missed saying that the workbook has 37 sheets.

    Thank you. your help is very well appreciated.

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Is next code what you need ...?
    Not sure that running for 31 sheets can be good ... where these sheets, at the beginning ???
    Please Login or Register  to view this content.

  15. #15
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Another code a bit smarter ...!
    Please Login or Register  to view this content.

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

    Re: VBA to Locate Duplicate value on two ranges of cells for the entire workbook.

    Different method
    Place the code onto ThisWorkbook code module.
    It runs each time you change any cell in that range in any sheet.
    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. Replies: 6
    Last Post: 02-14-2023, 03:21 AM
  2. [SOLVED] How to find the Duplicate Column Headers in entire workbook
    By sandeepgoud88 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-26-2019, 01:21 PM
  3. [SOLVED] How to lock the cell ranges automatically to protect entire workbook?
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-20-2014, 02:29 AM
  4. Duplicate entire workbook with values only
    By chris5001 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-05-2014, 11:32 PM
  5. Dynamic named ranges with entire workbook scope
    By jeffreybrown in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-29-2011, 10:16 AM
  6. Duplicate entire workbook
    By JChandler22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-31-2007, 02:28 AM
  7. [SOLVED] How do I delete duplicate records from an entire Excel workbook?
    By Steven B. in forum Excel General
    Replies: 0
    Last Post: 12-06-2005, 06:35 AM

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