mvandhu
09-03-2011, 04:21 AM
Need VBA code for the below mentioned scenario.
scenario:
I have 3 columns ID1, ID2, Name in sheet1 of my excel workbook.
Based on ID1 and ID2, my duplicate rows should be removed ie. the unique rows should be identified and the unique rows should be copied to my sheet2 (retain the 1st duplicate row).
For Example
Sheet1:
ID1 ID2 Name
1 a Jack
2 b Rose
1 a Emily
1 b Jill
2 b Jeni
So in the example above I want to retain my 1st duplicate row in my sheet 2.
ie in sheet 2 my result should be as
ID1 ID2 Name
1 a Jack
2 b Rose
1 b Jill
The rows count always varies in my sheet 1.
Please help me out in this.
Since am new to this Macros it will be better if you could put comment lines for each and every step of code on what the code is doing.
Also need another code to retain the last duplicate row.
Example
In shee1:
ID1 ID2 Name
1 a Jack
1 a Rose
2 b Jill
1 a Will
In sheet2, my result should be as
ID1 ID2 Name
1 a Will
2 b Jill
scenario:
I have 3 columns ID1, ID2, Name in sheet1 of my excel workbook.
Based on ID1 and ID2, my duplicate rows should be removed ie. the unique rows should be identified and the unique rows should be copied to my sheet2 (retain the 1st duplicate row).
For Example
Sheet1:
ID1 ID2 Name
1 a Jack
2 b Rose
1 a Emily
1 b Jill
2 b Jeni
So in the example above I want to retain my 1st duplicate row in my sheet 2.
ie in sheet 2 my result should be as
ID1 ID2 Name
1 a Jack
2 b Rose
1 b Jill
The rows count always varies in my sheet 1.
Please help me out in this.
Since am new to this Macros it will be better if you could put comment lines for each and every step of code on what the code is doing.
Also need another code to retain the last duplicate row.
Example
In shee1:
ID1 ID2 Name
1 a Jack
1 a Rose
2 b Jill
1 a Will
In sheet2, my result should be as
ID1 ID2 Name
1 a Will
2 b Jill