Solved

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

Posted on 2011-03-02
7
355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

751 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