+ Reply to Thread
Results 1 to 3 of 3

Comparing Two Columns in Excel Row By Row?

  1. #1
    Registered User
    Join Date
    06-05-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    39

    Comparing Two Columns in Excel Row By Row?

    I have currently browsed the forums and have came up with a code to compare two columns from two separate excel books and then highlight anything matching with the CompareRange. Here is a few more details about the problem:

    - I have two excel sheets. And data like this in each sheet:

    (First Sheet) (Second Sheet)
    •A B N O
    •7 .7 3 .56
    •6 .6 8 .45
    •5 .5 9 .55
    •4 .4 11 .2
    •3 .3 8 .22
    •2 .2 9 .55
    •1 .1 8 .54

    As you can see, given this example nothing should be highlighted once the macro is run since nothing from Column A or B from the first sheet matches directly with Column N & O from the second sheet. The problem is that with the macro (module) I have come up with will highlight "3" from Column A and ".2" from Column B, just because they appear in Column N & Column O respectivally.

    What I want: I only want a number to be highlighted if both the numbers "7" & ".7" are matched in the same row of Column N & Column O on the other spreadsheet. I have no idea how to do this. To be a little more precise, I'll give an example. Say I edited the data to be like this.

    (First Sheet) (Second Sheet)
    •A B N O
    •7 .7 3 .56
    •8 .45 8 .45
    •5 .5 9 .55
    •11 .4 11 .2
    •3 .3 8 .22
    •2 .2 9 .55
    •1 .1 8 .54

    With this data, I would want the second row of A & B ("8" & ".45") highlighted, while my error "3" of Column A and ".2" of Column B is not highlighted. Also, I would like it if row 4 of Column A & B ("11" & ".4") is not highlighted at all either, just because in O it is .2 and in B it would be .4 even though the 11's match.

    Please advise. Thanks in advance.

    Attached is the macro/module I have entered in which is working kind of correctly but producing the mistake.

    And also, (kind of a lesser problem), both the files with data will have the same header, example would be if Column A & Column N both had "Dogs" as it's title in Row 1 and Column B & O both had "Cats" as it's title in Row 1. Is there anyway the macro can be adjusted so it compares those two columns between the two workbooks without me even having to select or assigning a range? Thank you so much.

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    06-05-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Comparing Two Columns in Excel Row By Row?

    To expand on what I need, I need this Macro to be able to check if A1 appears anywhere in column N (say it shows up at N4), and if it does then go on to see if O4 matches B1. Only then, do I want cell A1 & B1 highlighted. Please advise.

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Comparing Two Columns in Excel Row By Row?

    Please Login or Register  to view this content.
    Last edited by protonLeah; 06-06-2013 at 01:43 AM.
    Ben Van Johnson

+ 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