+ Reply to Thread
Results 1 to 3 of 3

Comparing two sheets

Hybrid View

  1. #1
    Registered User
    Join Date
    11-18-2014
    Location
    Italy
    MS-Off Ver
    Excel 2010
    Posts
    2

    Comparing two sheets

    I can't go on with the comparing of two sheets in two different workbooks in Excel. What im trying to code is :

    From SHEET1, compare if column "E" is EQUAL to SHEET2 column "F" AND

    From SHEET1, compare if column "F" is EQUAL to SHEET2" column "I".

    If its not found , write in SHEET1 column "G" : "Not found"

    If its found do this :

    Compare SHEET1 if column "I" is EQUAL to SHEET2 column "AB" AND

    Compare SHEET1 if column "J" is EQUAL to SHEET2 column "AC"

    If BOTH compared values are the same then write in SHEET1 column "H" : "OK"

    THEN

    Compare SHEET1 if column "Y" is EQUAL to SHEET2 column "BW" AND

    Compare SHEET1 if column "Z" is EQUAL to SHEET2 column "BX"

    If BOTH compared values are the same then write in SHEET1 column "I" : "OK"

    NOTE THAT : Columns "F" - "I" - "E" - "F" contains the company name. All other columns contains € values.

    EDIT #1 :

    The compare is Row by Row . Each Row of SHEET1 to SHEET2 rows ( there are for SURE more rows in SHEET2 ) , The length of columns is the same as how many rows are in the sheet.

    Thanks .

  2. #2
    Registered User
    Join Date
    10-29-2014
    Location
    Portland, OR
    MS-Off Ver
    MS Office 2013
    Posts
    54

    Re: Comparing two sheets

    It looks like you need an IF/ISNA string. I'm not entirely sure how the string would look but I believe it would start out with something similar to..
    Formula: copy to clipboard
    =IF(ISNA(E='Sheet2'!F:F)....etc etc..

    Hopefully that puts you on the right path for researching a solution.

    Kind Regards,

    Tommy Bailey

  3. #3
    Registered User
    Join Date
    11-18-2014
    Location
    Italy
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Comparing two sheets

    I've write that code:

    Sub test()
        Dim wb1 As Workbook: Set wb1 = Workbooks.Open("C:\A.xlsx")
        Dim wb2 As Workbook: Set wb2 = Workbooks.Open("C:\B.xls")
        Dim tohere As Worksheet: Set tohere = wb1.Sheets("Attivaz_201408_FL")
        Dim fromhere As Worksheet: Set fromhere = wb2.Sheets("Attivaz_201408")
        Dim wk1 As Workbook: Set wk1 = Workbooks("A.xlsx") ' da cambiare casomai
        Dim sh1 As Worksheet: Set sh1 = wk1.Worksheets("Attivaz_201408_FL")
        Dim Ur As Long, X As Long
        Ur = tohere.Range("E" & Rows.Count).End(xlUp).Row
        wk1.Activate
        sh1.Range("G2").FormulaR1C1 = _
            "=IF(AND([A.xlsx]Attivaz_201408_FL!RC5=[B.xls]Attivaz_201408!RC6,[A.xlsx]Attivaz_201408_FL!RC6=[B.xls]Attivaz_201408!RC7),""trovata"",""Non trovata"")"
        Range("H2").Select
        sh1.Range("H2").FormulaR1C1 = _
            "=IF(AND([A.xlsx]Attivaz_201408_FL!RC9=[B.xls]Attivaz_201408!RC28,[A.xlsx]Attivaz_201408_FL!RC10=[B.xls]Attivaz_201408!RC29),""OK"",""NO"")"
        Range("I2").Select
        sh1.Range("I2").FormulaR1C1 = _
            "=IF(AND([A.xlsx]Attivaz_201408_FL!RC25=[B.xls]Attivaz_201408!RC75),""OK"",""NO"")"
        sh1.Range("G2:I2").AutoFill Destination:=Range("G2:I" & Ur), Type:=xlFillDefault
    
    'wb1.Close SaveChanges:=False
    'wb2.Close SaveChanges:=False
    
    Set wb1 = Nothing
    Set wb2 = Nothing
    Set tohere = Nothing
    Set fromhere = Nothing
    Set sh1 = Nothing
    Set wk1 = Nothing
    End Sub
    But its comparing wrong the columns since its not sure that e.g. SHEET1 column X1 is the located in SHEET2 column X1

+ 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. [SOLVED] Comparing two sheets!
    By melkon99 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-05-2012, 04:55 PM
  2. Comparing 2 sheets
    By komet12 in forum Excel General
    Replies: 8
    Last Post: 12-12-2011, 10:11 AM
  3. comparing within 2 sheets
    By p_dhoke in forum Excel General
    Replies: 2
    Last Post: 07-20-2007, 04:28 AM
  4. [SOLVED] comparing sheets
    By Newbie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2006, 05:20 AM
  5. [SOLVED] Comparing Two Sheets
    By Pete Petersen in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-20-2005, 04:06 AM

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