+ Reply to Thread
Results 1 to 17 of 17

compare data from two different sheets in same workbook

  1. #1
    Forum Contributor
    Join Date
    10-21-2012
    Location
    Ind
    MS-Off Ver
    Excel 2010
    Posts
    110

    Post compare data from two different sheets in same workbook

    hello all,

    i am facing problems. need your help on below problem.

    i do have one workbook. please find attached example workbook. in that workbooks i do have 4 sheets that is fpl,ldn,result matched and result unmatched. i need to compare fpl col c to ldn col d. if cell is matching perfectly then then macro must highlight that row in green color in both sheets. if cell is not matching then macro will highlight that row in red color in both sheets. the another thing is i need to copy matched rows from both sheet and paste in result matched sheet. the same activity i must do with unmatched cell that is those cells which are not matching and we highlighted in red color must paste into result unmatched sheet.

    guys every i received minimum 2000 rows data and its very tedious task to do that. i use excel 2010.

    please help me.....
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    10-21-2012
    Location
    Ind
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: compare data from two different sheets in same workbook

    plzzzz help me...........

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: compare data from two different sheets in same workbook

    Hello akulka58,

    You could use Conditional Format to do this.

    Please look at the attached Workbook, to give you an idea. You may change it to best suit your needs.

    Also see the "Please consider" note at the bottom of this post.
    Attached Files Attached Files
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Contributor
    Join Date
    10-21-2012
    Location
    Ind
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: compare data from two different sheets in same workbook

    i am looking for code

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: compare data from two different sheets in same workbook

    These code would do much you have asked, but not everything. It onlly highlightes one sheet, but not both sheets. The find function works okay but not with large data, as the speed becomes an issue. I have also assumed , you want to colour and copy the entire row, but if you just wanted a single cell, just delete the word "Entire" from the code.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    10-21-2012
    Location
    Ind
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: compare data from two different sheets in same workbook

    hi ab33. you given me xmas gift. thanks a lot. u are real guru of vba. thanks a lot..... wish you happy xmas n new year............

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: compare data from two different sheets in same workbook

    You are welcome!
    Thanks for kind words and wish you the same too!

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: compare data from two different sheets in same workbook

    @ AB33,

    Nice work! To select single Cells, I have replaced EntireRow with Cells, and copied the results to Column D instead of Column A. I have also added Option Explicit and Dim NR as Integer, in both subs, which makes the Project more robust.

    If akulka58 wants to select single Cells instead, this Code should suffice.

    Please Login or Register  to view this content.
    Hope you don't mind.

    Happy Holidays, and a Merry Christmas to you Guys!

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: compare data from two different sheets in same workbook

    Winon,
    No at all, in fact quite the opposite, it can only enhance my knowledge.
    Wish you the same!

  10. #10
    Forum Contributor
    Join Date
    10-21-2012
    Location
    Ind
    MS-Off Ver
    Excel 2010
    Posts
    110

    Unhappy Re: compare data from two different sheets in same workbook

    thanks. i am so sorry because i need one amendment in this. code must copy matched rows in result matched sheet. it means the cell which is matching in ldn and fpl should be there in result matched sheet. it will be very very helpful for me. you guys already taken lots of effort i know that but i dont have any choice. i must tell you this.

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: compare data from two different sheets in same workbook

    Hello akulka58,

    AB33 has already stated that Code could slow down your project with large data.

    The find function works okay but not with large data, as the speed becomes an issue.
    Why then must it be in Code, if Conditional Format does it just as well using much less System resources?

    See revised WorkBook with Conditional Formatting, which does exactly what you are asking for.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: compare data from two different sheets in same workbook

    Please note that by "Matching" you mean matching the row numbers. For e.g if you have a value found in sheet 1 is in row 3, the matching row to be find in another sheet, let say sheet 2 would be in row 3 too. Therefore, the rows in sheets ldn and fpl would match the rows on the other two sheets. The columns could be changed though. I hope this is what you meant. You should also put the word "Header" on both sheets in row 1 column C(For matched) and D(Unmatched)

    Amended code

    Please Login or Register  to view this content.
    Last edited by AB33; 12-25-2012 at 05:03 PM.

  13. #13
    Forum Contributor
    Join Date
    10-21-2012
    Location
    Ind
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: compare data from two different sheets in same workbook

    no no your previous code was totally fine. i just need to paste rows in matched result sheet. for example in ldn sheet we have 200 number and in fpl sheet we have 200 number. i need both 200 number rows from both sheet pasted in matched sheet.

  14. #14
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: compare data from two different sheets in same workbook

    Hello akulka58,

    Just to clarify.

    in ldn sheet we have 200 number and in fpl sheet we have 200 number. i need both 200 number rows from both sheet pasted in matched sheet
    You do not say where in the matched sheet you want to copy this data to.

    Do you want it in the same column as it showed in Sheet ldn with AB33's previous Code?

  15. #15
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: compare data from two different sheets in same workbook

    Akulka,
    I am now compeltley lost you. I do not know which 200 rows you are referring to. My first code copies all your data, regardless on the number of rows you may have. You need to show me with a sample what you wish to do and what is missing from my code?

  16. #16
    Forum Contributor
    Join Date
    10-21-2012
    Location
    Ind
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: compare data from two different sheets in same workbook

    sorry. forgive me. plz find attached file.
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: compare data from two different sheets in same workbook

    The matched sheet has now values from both sheets, but I can not do the same for the unmatched as the name says, if they values do not match from both sheets, I can not copy from both sheets either.
    It is really hard to code as you have many blanks with just values in a column, it would be easier to use the next empty row, but most of your data are empty. I have also copied the entire row in case you wanted the other rows too. If you just wanted to copy only the value, replace these lines

    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.
    and these two lines

    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ 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