Consulting

Results 1 to 6 of 6

Thread: Compare two columns varying in number of rows on different sheets

  1. #1

    Compare two columns varying in number of rows on different sheets

    Hello to all,

    I have two sheets, namely 'Company 1' and 'Company 2'. Each sheet has a column (F), namely 'ship number'. Company 1 has 12,500 rows and Company 2 has 350 rows. I would like to check if any of the ship numbers in company 2 are in company 1. If a ship number exists in Company 1, then I would like to highlight that row in Company 1 or least the column/cell, but the row would be really nice. I would then like to filter the results somehow. Many thanks.

    Regards

    JDS_916

  2. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I am out the door in just a minute. I'm sure that someone will be along shortly, but if you want to try for yourself (this is NOT code, just an idea spark for you.)

    Dim X As Range
    For each Cel in Company 2
    Set X = Company 1. Find ( Cel  )
    If not X is nothing then X.entireRow .Interior.Colorindex = 7
    Next
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    You can do this with conditional formatting, using a formula, of the ilk:
    =ISNUMBER(MATCH($F3,Sheet2!$F:$F,0))
    applied to either entire rows, or just several columns (being the extent of the data), then you can filter on colour (depending on which version of Excel you have).

    It would be easier for me to show this on a sample file provided by you to save me (a) having to make up a sample file and (b) to save me guessing wrongly anyrthing about your file/sheets/data. Anonymise the data first if it's sensitive data.
    Last edited by p45cal; 11-09-2014 at 01:04 PM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    Hi p45cal,

    Thanks very much for responding. I've uploaded the file. As I've tried to explain, if any of the numbers in column F on Company 2 sheet match any of those in column F on Company 1 sheet highlight the number or row on Company 1 sheet.

    Regards,

    JDS_916
    Attached Files Attached Files

  5. #5
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    In the attached, there is conditional formatting applied to A2:K12993. Formula:
    =ISNUMBER(MATCH(CHAR(160) & $F2,'Company 2'!$F:$F,0))
    It is autofiltered by colour using column F.

    This was additionally complicated by the values in Company 2 column F all being prefixed by a non-breaking space (ascii code 160); for this to work properly they must ALL be prefixed by this character. Alternatively, you could remove this character from the cells and obtain a simpler and more reliable conditional format formula.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  6. #6
    Works like a treat p45cal. Thanks a lot for your time and expertise.

    Regards,

    JDS_916

Posting Permissions

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