Solved

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

Posted on 2011-03-02
7
353 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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 500 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

856 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