+ Reply to Thread
Results 1 to 16 of 16

Finding sheet duplication using excel VBA.

  1. #1
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Finding sheet duplication using excel VBA.

    I need help in finding duplications within different tables within different sheets.

    Sheet 1, shows an table (column A:F) as the following below:


    1. US31397EWR25 FHR 3281 FT ABS CVR 10-16 11,220,000
    2. US31397YTK72 FHR 3500 SE RMBS TALK 10-16 21,933,000
    3. US31397PM493 FHR 3397 GS RMBS TALK 16-08 25,289,000
    4. US31396VP850 FNR 2007-42 SD RMBS TALK 16-16 18,985,000
    5. US31396YTV47 FNR 2008-20 SA RMBS TALK 13-16 13,359,000
    6. US31395NN458 FNR 2006-58 SQ RMBS TALK 14-16 10,588,000
    7. US31396PFR73 FNR 2006-124 SC RMBS TALK 15-00 21,509,000
    8. US31396PVQ17 FNR 2007-23 SI RMBS TALK 16-00 20,115,000
    9. US31396W3B04 FNR 2007-75 PI RMBS TALK 17-00 39,740,000
    10. US31397WZL26 FHR 2009 GH CMBS TALK 15-45 13,675,000

    Sheet 2, shows the same table (column A:F) as above. However due to some other calculation the table is formatted longer in length, such as seen below:

    3. US31397EWR25 FHR 3281 CI RMBS TALK 15-16 11,220,000
    4. US31397YTK72 FHR 3500 SE RMBS TALK 10-16 21,933,000
    5. US31397PM493 FHR 3397 GS RMBS TALK 16-08 25,289,000
    6. US31396VP850 FNR 2007-42 SD RMBS TALK 16-16 18,985,000
    7. US31396YTV47 FNR 2008-20 SA RMBS TALK 13-16 13,359,000
    8. US31395NN458 FNR 2006-58 SQ RMBS TALK 14-16 10,588,000
    9. US31396PFR73 FNR 2006-124 SC RMBS TALK 15-00 21,509,000
    10. US31396PVQ17 FNR 2007-23 SI RMBS TALK 16-00 20,115,000
    11. US31396W3B04 FNR 2007-75 PI RMBS TALK 17-00 39,740,000
    12. US31397WZL26 FHR 3485 SI RMBS TALK 15-00 13,675,000

    I want to know, how can I show in sheet 2 table the duplication from sheet 1 table using the excel VBA.
    The output is shown in sheet 2, through highlighting the same duplications as the table in sheet 1:

    Sheet 2:
    3. US31397EWR25 FHR 3281 CI RMBS TALK 15-16 11,220,000
    4. US31397YTK72 FHR 3500 SE RMBS TALK 10-16 21,933,000
    5. US31397PM493 FHR 3397 GS RMBS TALK 16-08 25,289,000
    6. US31396VP850 FNR 2007-42 SD RMBS TALK 16-16 18,985,000
    7. US31396YTV47 FNR 2008-20 SA RMBS TALK 13-16 13,359,000
    8. US31395NN458 FNR 2006-58 SQ RMBS TALK 14-16 10,588,000
    9. US31396PFR73 FNR 2006-124 SC RMBS TALK 15-00 21,509,000
    10. US31396PVQ17 FNR 2007-23 SI RMBS TALK 16-00 20,115,000
    11. US31396W3B04 FNR 2007-75 PI RMBS TALK 17-00 39,740,000
    12. US31397WZL26 FHR 3485 SI RMBS TALK 15-00 13,675,000

    Row 3 and 12 are different due to the difference between sheet 1 and sheet 2 tables.

    Thank you for your time and help.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Finding sheet duplication using excel VBA.

    What difference are you talking about? Maybe it will be good if you explain using a sample sheet.

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Re: Finding sheet duplication using excel VBA.

    I need help in finding duplication within different worksheet tables.

    I want to know, how can I show in sheet 2 table the duplication from sheet 1 table using the excel VBA.
    The output is shown in sheet 2, through highlighting the same duplications as the table in sheet 1(please see attachment):

    Thank you for your time and help.

    Any help appreciated.




    duplicate tables.xlsx

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Finding sheet duplication using excel VBA.

    Should all the columns be compared while identifying duplicates?

  5. #5
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Re: Finding sheet duplication using excel VBA.

    Dear arlu201

    Ideally yes, all the columns need to be checked to be able to identify the duplication as i tired it with certain columns using if function formulas and it does not show the desired output.

    Thank you for your time and response.

    Kind regards
    Misbah

  6. #6
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Re: Finding sheet duplication using excel VBA.

    Dear arlu201,

    I tired using this If function formula:
    =IF(AND($F2=Sheet1!$F2,$H2=Sheet1!$H2,$E2=Sheet1!$E2,$G2=Sheet1!$G2),Sheet1!I1,"").

    But it does not show me the desired output in the sheet 2'a table.

    I would really appreciate the help in finding the duplication.

    Thank you for your time and help.

    Kind regards
    Misbah

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Finding sheet duplication using excel VBA.

    You have lots of blank cells in columns A & B of both sheets. That will affect the dup check. What do you want to do about it?

  8. #8
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Re: Finding sheet duplication using excel VBA.

    is it possible for the duplication to take into also the black cells in column A or B. Each row in sheet 1 needs to be compared with sheet 2 table, to find accurate duplication, if possible.

    is this plausible problem?

    Thank you for your time and response.

    I am very grateful to your help!

    Kind regards
    Miss

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Finding sheet duplication using excel VBA.

    So if a particular row has 1 blank cell in column A but the other sheet does not have the blank cell for the same row, it will be flagged as non-duplicate?

  10. #10
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Re: Finding sheet duplication using excel VBA.

    Yes.

    It should be able to read the column's such as ISINs and name accurately compared to other sheet.

    Thank you for your help and response.

  11. #11
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Re: Finding sheet duplication using excel VBA.

    Dear arlu1201

    I found this VB function which allows to find duplicates within various sheet and display the data in sheet 1.

    I am currently trying to manipulate this code below, so it compares all the table ranges on sheet 1 with sheet2 instead of the first rows.
    I am getting compiling errors with the code below and would appreciate any help.

    Please Login or Register  to view this content.
    Thank you so much for your help and time.

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Finding sheet duplication using excel VBA.

    I worked out this code for you -
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

    However, i didnt find any duplicates because of the Price Type field. All other fields were matching to make the rows duplicate but there was a difference in the Price Type field which was not allowing the code to consider it as a duplicate.

  13. #13
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Re: Finding sheet duplication using excel VBA.

    Dear arlu1201,

    Thank you so much for your help on this problem. I am very grateful to your help.

    The code deletes last 10 rows of sheet 2 data, when its run, I am not sure why?

    I have attached the file excel file with code in sheet 2.

    Test duplication.xlsm

    i have also attached the code below for further references.

    Please Login or Register  to view this content.
    If could please help me out with this small problem, i would be very grateful.

    Thank you for your time and help.

    Many thanks
    Miss

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Finding sheet duplication using excel VBA.

    You need to put the code in a standard module (see steps below) and not in the sheet2 code window.

    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

  15. #15
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Re: Finding sheet duplication using excel VBA.

    Dear arlu1201,

    Thank you for your response and help.

    However, I copied the code into the workbook module and it still deletes the last 10 rows of sheet 2 data.

    I still can not figure out why it does that.

    Any assistant would be very helpful.

    Thank you for your time and help.

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Finding sheet duplication using excel VBA.

    There was a small error in the code. Try this one
    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