+ Reply to Thread
Results 1 to 5 of 5

Compare Ranges with vba

  1. #1
    Registered User
    Join Date
    09-23-2020
    Location
    US
    MS-Off Ver
    Ofice 16
    Posts
    22

    Compare Ranges with vba

    I'm looking for a solution to compare 2 ranges of data. I'd like to find a vba solution if possible.

    I'd like to compare the data in F6:J50 with the data in A6:E50 and if there is anything missing or that doesn't match be highlighted in the Light Red (Bad Cell Format) color and if there is anything in A6:E50 that isn't found in F6:J50 be highlighted in the neutral Yellow cell format.

    If I'm going about this all wrong and there's another much simpler way of executing this by all means please set me straight. I've included a sample spreadsheet with example data for someone to play with.

    I did experiment with the compare cells function of Kutools and while it worked and did pretty much what I wanted the process was extremely slow.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Compare Ranges with vba

    You can do this with Conditional Formatting.

    Select A6:F50. The formulas will automatically adjust for each selected cell.

    Conditional Format Rule 1 Formula (Yellow)
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Conditional Format Rule 2 Formula (RED)
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    You could do the same for the F:J section by adapting the same formulas.
    Last edited by AlphaFrog; 06-09-2021 at 09:28 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    09-23-2020
    Location
    US
    MS-Off Ver
    Ofice 16
    Posts
    22

    Re: Compare Ranges with vba

    It seems to be working pretty good, but It's highlighting the opposite. All the values that match are highlighted red and when I make a change in F6:J50 to force one to not match it formats the cell back to white. Is there any way to flip flop this where the non matching cells are the ones highlighted red.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Compare Ranges with vba

    Conditional Format Rule 2 Formula (RED)
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 06-09-2021 at 09:27 AM.

  5. #5
    Registered User
    Join Date
    09-23-2020
    Location
    US
    MS-Off Ver
    Ofice 16
    Posts
    22

    Re: Compare Ranges with vba

    Beautiful! I'm thankful for the help and the quick reply!

+ 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. Compare Ranges
    By Pirvu Vali in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-18-2019, 11:19 AM
  2. [SOLVED] Compare two ranges
    By mattress58 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-23-2014, 08:15 AM
  3. compare two ranges
    By anilg0001 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2013, 03:20 AM
  4. [SOLVED] Compare two Ranges
    By jbmerrel in forum Excel General
    Replies: 5
    Last Post: 04-06-2012, 03:04 PM
  5. Compare Two Ranges
    By macro_beta in forum Excel General
    Replies: 6
    Last Post: 10-04-2010, 10:10 AM
  6. Excel 2007 : Compare two ranges
    By ccpsc in forum Excel General
    Replies: 2
    Last Post: 09-09-2010, 04:11 AM
  7. compare min and max ranges
    By carylee557 in forum Excel General
    Replies: 2
    Last Post: 11-03-2008, 11:16 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