Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how can i remove duplicate values from the excel sheet ??

Posted on 2011-03-02
7
Medium Priority
?
359 Views
Last Modified: 2012-05-11
i want to know that how can i remove duplicate values from the excel sheet using excel macros??

here i attach the excel sheet as well as attached snapshot ...

please refer the attached document ....
0
Comment
Question by:Parth48
  • 4
  • 3
7 Comments
 
LVL 50

Expert Comment

by:Dave Brett
ID: 35024509
Nothing attached :)


But my The Duplicate Master" at this EE article link, http://www.experts-exchange.com/A_2123.html

will handle your requests with functionality for the entireworbook, one, several or all columns in a row etc

Cheers

Dave
0
 

Author Comment

by:Parth48
ID: 35024512
please refer the attached files ...


Test.xlsx
03-03-2011-11-39-45-AM.jpg
0
 

Author Comment

by:Parth48
ID: 35024516
in attached snapshot i want to remove duplicate values from marked area (using red line) ...
using macros (including for loop)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 50

Expert Comment

by:Dave Brett
ID: 35024526
what do you define as a dupe?

- any individual cell that is replicated
- matching an entire row
- matching an entire column (D and F)

My addin will handle the first two, not the last

And do you specifically want code that you can see (the addin is code), and if so why - for you to modify?

Cheers

Dave
0
 

Author Comment

by:Parth48
ID: 35024852
matching an entire column (A,B,C,D,E and F) (not rows)
0
 
LVL 50

Accepted Solution

by:
Dave Brett earned 2000 total points
ID: 35024932

Sample attached

The code runs on a user prompted range, the default being the current selection

While the code could be a litlte shorter I have used arrays for a speed gain over range looops

This line is to show thecolumn(s) contents removed
you can take it out
.Interior.Color = vbYellow

Cheers

Dave
Sub DupSel()
    Dim rng1 As Range
    Dim rng2 As Range
    Dim X
    Dim lcol As Long
    Dim lrow As Long
    Dim strTmp
    Dim objDic
    Set objDic = CreateObject("scripting.dictionary")
    Set rng1 = Application.InputBox("Please select range", , Selection.Address, , , , , 8)
    X = rng1
    For lcol = 1 To UBound(X, 2)
        strTmp = vbNullString
        For lrow = 1 To UBound(X, 1)
            strTmp = strTmp & X(lrow, lcol)
        Next lrow
        If Not objDic.exists(strTmp) Then
            objDic.Add strTmp, 1
        Else
            If Not rng2 Is Nothing Then
                Set rng2 = Union(rng2, rng1.Cells(1).Offset(0, lcol - 1).Resize(lrow - 1, 1))
            Else
                Set rng2 = rng1.Cells(1).Offset(0, lcol - 1).Resize(lrow - 1, 1)
            End If
        End If
    Next lcol
    If Not rng2 Is Nothing Then
        With rng2
            .ClearContents
            .Interior.Color = vbYellow
        End With
    End If
End Sub

Open in new window

test.xlsm
0
 

Author Comment

by:Parth48
ID: 35026254
hi @brettdj: Thanks very much ...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Progress

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question