+ Reply to Thread
Results 1 to 4 of 4

Automatic compare

  1. #1
    Registered User
    Join Date
    11-08-2009
    Location
    Poland
    MS-Off Ver
    Excel 2003
    Posts
    1

    Automatic compare

    Hello it's my first time so sorry for any mistake.
    I tried make macro which will compare to columns, one in one worksheet second in another. Of corse it sholud make it automaticly becouse i need compare about 2500 cells. Works fie but when I use "x" and "y" in IF formule I cant see masbox which sholud apper. When I put values for example x=5 it work. Why doesn't work with variables.
    I make something like that :


    Please Login or Register  to view this content.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Automatic compare

    If this is a one off exercise, you might be better using the COUNTIF function. If you use a formula like

    Please Login or Register  to view this content.
    pasted into B1 in your second sheet, it will tell you how many times the value in A1 in the second sheet appears in the first sheet. If you get a zero then it isn't there.

    I've assumed that the columns of interest are Column A in both sheets for the example above.

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Automatic compare

    Hi lenovomaniac
    Your code seems to work fine for me (after removing the comment out from Worksheets(1).Activate). I've attached the workbook I used to run a test on your code. It throws
    Please Login or Register  to view this content.
    when it finds a match from sheet 2 column A in sheet 1 column L.
    It appears from your code that this is what you are looking for. If not, explain further what you're trying to do and perhaps I can help.
    John
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Automatic compare

    There are many ways to do this, and many ways faster than the one below. The significant changes are (1) eliminating Selecting scells, and (2)move the data capture from the first worksheet outside the inner loop, eliminating duplication.
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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