PC Review


Reply
Thread Tools Rate Thread

Delete Duplicate data row wise from each cell

 
 
tarone@gmail.com
Guest
Posts: n/a
 
      29th Jan 2007
I have a big file and I want to delete duplicate data in rows
separated by comma in same cell

i.e

Sample File

COL A
Pepsi Cola, Coke, Pepsi Cola, Toyota Mercedes, M700, Toyota, Tom,
Peter, Coke
Pepsi Cola
Pepsi Cola, Coke, Coke
Tom, Peter, Mike, Don, Paul, Tom, Mike
Pepsi Cola, Coke, Pepsi Cola, Toyota Mercedes, Toyota
M700, M700
There are like 10,000 rows like this
.....
...


Required File
Pepsi Cola, Coke, Toyota Mercedes, M700, Toyota, Tom, Peter
Pepsi Cola
Pepsi Cola, Coke
Tom, Peter, Mike, Don, Paul
Pepsi Cola, Coke, Toyota Mercedes
M700
There are like 10,000 rows like this
.....
...


Required: We just want to delete the duplicate data ROW WISE from same
cell

Any solution will be appreciated

Regards

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      29th Jan 2007
You could try a UDF. If your data is in A1 and your delimiter is a comma,
the syntax is

=rmvDupes(A1, ",")

more here if you are new to VBA:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


Function RmvDupes(varData As String, _
strDelimiter As String) As String
Dim lngPos1 As Long

On Error GoTo ExitFunction
varData = Trim(varData)
If Right(varData, 1) <> strDelimiter And _
Len(varData) > 0 Then _
varData = varData & strDelimiter
lngPos1 = InStr(1, varData, strDelimiter, vbTextCompare)
If lngPos1 > 0 Then
RmvDupes = Left(varData, lngPos1) & " " & _
Replace(RmvDupes(Trim(Right(varData, _
Len(varData) - lngPos1)), strDelimiter), _
Left(varData, lngPos1), "", 1, -1, vbTextCompare)
If Right(Trim(RmvDupes), 1) = strDelimiter Then _
RmvDupes = Left(Trim(RmvDupes), _
Len(Trim(RmvDupes)) - 1)
RmvDupes = Application.Trim(RmvDupes)
End If

ExitFunction:

End Function

"(E-Mail Removed)" wrote:

> I have a big file and I want to delete duplicate data in rows
> separated by comma in same cell
>
> i.e
>
> Sample File
>
> COL A
> Pepsi Cola, Coke, Pepsi Cola, Toyota Mercedes, M700, Toyota, Tom,
> Peter, Coke
> Pepsi Cola
> Pepsi Cola, Coke, Coke
> Tom, Peter, Mike, Don, Paul, Tom, Mike
> Pepsi Cola, Coke, Pepsi Cola, Toyota Mercedes, Toyota
> M700, M700
> There are like 10,000 rows like this
> .....
> ...
>
>
> Required File
> Pepsi Cola, Coke, Toyota Mercedes, M700, Toyota, Tom, Peter
> Pepsi Cola
> Pepsi Cola, Coke
> Tom, Peter, Mike, Don, Paul
> Pepsi Cola, Coke, Toyota Mercedes
> M700
> There are like 10,000 rows like this
> .....
> ...
>
>
> Required: We just want to delete the duplicate data ROW WISE from same
> cell
>
> Any solution will be appreciated
>
> Regards
>
>

 
Reply With Quote
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      30th Jan 2007
some corrections, I had hardcoded the length of the delimiter (using 1).
this should work better.

Function RmvDupes(varData As String, _
strDelimiter As String) As String
Dim lngPos1 As Long

On Error GoTo ExitFunction
varData = Trim(varData)
If Right(varData, Len(strDelimiter)) <> _
strDelimiter And Len(varData) > 0 Then _
varData = varData & strDelimiter
lngPos1 = InStr(1, varData, strDelimiter, vbTextCompare)
If lngPos1 > 0 Then
RmvDupes = Left(varData, lngPos1 + _
Len(strDelimiter) - 1) & " " & _
Replace(RmvDupes(Trim(Right(varData, _
Len(varData) - lngPos1 - _
Len(strDelimiter) + 1)), strDelimiter), _
Left(varData, lngPos1 + Len(strDelimiter) - 1), _
"", 1, -1, vbTextCompare)
If Right(Trim(RmvDupes), _
Len(strDelimiter)) = strDelimiter Then _
RmvDupes = Left(Trim(RmvDupes), _
Len(Trim(RmvDupes)) - Len(strDelimiter))
RmvDupes = Application.Trim(RmvDupes)
End If

ExitFunction:

End Function


"JMB" wrote:

> You could try a UDF. If your data is in A1 and your delimiter is a comma,
> the syntax is
>
> =rmvDupes(A1, ",")
>
> more here if you are new to VBA:
> http://www.mvps.org/dmcritchie/excel/getstarted.htm
>
>
> Function RmvDupes(varData As String, _
> strDelimiter As String) As String
> Dim lngPos1 As Long
>
> On Error GoTo ExitFunction
> varData = Trim(varData)
> If Right(varData, 1) <> strDelimiter And _
> Len(varData) > 0 Then _
> varData = varData & strDelimiter
> lngPos1 = InStr(1, varData, strDelimiter, vbTextCompare)
> If lngPos1 > 0 Then
> RmvDupes = Left(varData, lngPos1) & " " & _
> Replace(RmvDupes(Trim(Right(varData, _
> Len(varData) - lngPos1)), strDelimiter), _
> Left(varData, lngPos1), "", 1, -1, vbTextCompare)
> If Right(Trim(RmvDupes), 1) = strDelimiter Then _
> RmvDupes = Left(Trim(RmvDupes), _
> Len(Trim(RmvDupes)) - 1)
> RmvDupes = Application.Trim(RmvDupes)
> End If
>
> ExitFunction:
>
> End Function
>
> "(E-Mail Removed)" wrote:
>
> > I have a big file and I want to delete duplicate data in rows
> > separated by comma in same cell
> >
> > i.e
> >
> > Sample File
> >
> > COL A
> > Pepsi Cola, Coke, Pepsi Cola, Toyota Mercedes, M700, Toyota, Tom,
> > Peter, Coke
> > Pepsi Cola
> > Pepsi Cola, Coke, Coke
> > Tom, Peter, Mike, Don, Paul, Tom, Mike
> > Pepsi Cola, Coke, Pepsi Cola, Toyota Mercedes, Toyota
> > M700, M700
> > There are like 10,000 rows like this
> > .....
> > ...
> >
> >
> > Required File
> > Pepsi Cola, Coke, Toyota Mercedes, M700, Toyota, Tom, Peter
> > Pepsi Cola
> > Pepsi Cola, Coke
> > Tom, Peter, Mike, Don, Paul
> > Pepsi Cola, Coke, Toyota Mercedes
> > M700
> > There are like 10,000 rows like this
> > .....
> > ...
> >
> >
> > Required: We just want to delete the duplicate data ROW WISE from same
> > cell
> >
> > Any solution will be appreciated
> >
> > Regards
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete duplicate data in a single cell kacey28 Microsoft Excel Worksheet Functions 10 24th Jun 2008 04:59 PM
delete duplicate data in the same cell elaine Microsoft Excel Programming 6 13th Dec 2006 04:55 PM
Data row wise, formula column wise Fred Smith Microsoft Excel Misc 4 9th Dec 2005 03:48 PM
Delete row wise duplicates & colomun wise simultaneously excel =?Utf-8?B?RGlwYW5rYXI=?= Microsoft Excel Worksheet Functions 0 6th Oct 2005 01:14 PM
Delete duplicate data in SAME CELL Tom Microsoft Excel Worksheet Functions 5 4th Jul 2003 10:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:25 PM.