Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Delete Duplicate data row wise from each cell

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Delete Duplicate data row wise from each cell

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

" 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Delete Duplicate data row wise from each cell

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

" 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete duplicate data in a single cell kacey28 Excel Worksheet Functions 10 June 24th 08 04:59 PM
delete duplicate data in the same cell elaine Excel Programming 6 December 13th 06 04:55 PM
How to delete duplicate data PL New Users to Excel 9 September 1st 06 03:47 AM
Data row wise, formula column wise Fred Smith Excel Discussion (Misc queries) 4 December 9th 05 03:48 PM
Delete row wise duplicates & colomun wise simultaneously excel Dipankar Excel Worksheet Functions 0 October 6th 05 01:14 PM


All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"