Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
mat mat is offline
external usenet poster
 
Posts: 37
Default Delete Duplicate codes in a cell

Hi Everyone,

I have cell data, arranged in rows arranged entirely in one column, each
cell contain many codes. Ideally each cell should have a unique set of codes
(could be more than one).

I would like to eliminate all the duplicate codes and keep only one of each
code.

The example cells are as follows;

FA,FA,FS,FS,FZ
FO,FA,FS,FO
FO,FO,FO

Does anyone have any idea as to what I might do in order to make the
following happen:

1) FA,FS,FZ
2) FO,FA,FS
3) FO


Any suggestions are sincerely appreciated.

Thanks Mat

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Delete Duplicate codes in a cell

It is complicated need a macro.

Sub removedups()
Dim MyArray()

Set tmpsht = Sheets.Add

Set MyRange = Application.InputBox(Prompt:="Select Range of cells", _
Title:="Input Cells", _
Type:=8)

For Each cell In MyRange
tmpsht.Cells.ClearContents
Set MyCell = Nothing
'split cellaround coomas
MyCell = Split(cell, ",")

With tmpsht
'put data into temp sheet
RowCount = 1
For Each word In MyCell
.Range("A" & RowCount) = word
RowCount = RowCount + 1
Next word

LastRow = .Range("A" & RowCount).End(xlUp).Row

'copy unique values to column B
.Range("A1:A" & LastRow).AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=.Range("B1"), _
Unique:=True

If .Range("B1") = .Range("B2") Then
.Range("B1").Delete shift:=xlUp
End If
LastRow = .Range("B" & RowCount).End(xlUp).Row
'Sort Data
.Range("B1:B" & LastRow).Sort _
Header:=xlNo, _
key1:=.Range("b1"), _
Order1:=xlAscending


'put data back into an arra
ReDim MyArray(0 To (LastRow - 1))
For RowCount = 1 To LastRow
MyArray(RowCount - 1) = Range("B" & RowCount)
Next RowCount
End With

cell.Offset(0, 1) = Join(MyArray, ",")
Next cell

Application.DisplayAlerts = False
tmpsht.Delete
Application.DisplayAlerts = True

End Sub


"Mat" wrote:

Hi Everyone,

I have cell data, arranged in rows arranged entirely in one column, each
cell contain many codes. Ideally each cell should have a unique set of codes
(could be more than one).

I would like to eliminate all the duplicate codes and keep only one of each
code.

The example cells are as follows;

FA,FA,FS,FS,FZ
FO,FA,FS,FO
FO,FO,FO

Does anyone have any idea as to what I might do in order to make the
following happen:

1) FA,FS,FZ
2) FO,FA,FS
3) FO


Any suggestions are sincerely appreciated.

Thanks Mat

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
Finding Duplicate UPC Codes in 1 Column JeremyH1982 Excel Discussion (Misc queries) 7 January 30th 10 01:47 AM
Delete duplicate cell PointerMan Excel Worksheet Functions 4 March 4th 09 04:38 AM
Duplicate account codes that total amount MMM Excel Discussion (Misc queries) 3 July 22nd 08 11:59 PM
Delete duplicate data in a single cell kacey28 Excel Worksheet Functions 10 June 24th 08 04:59 PM
How can delete the duplicate word from a string in cell in EXCEL Laxman A Patil Excel Discussion (Misc queries) 1 May 12th 06 03:04 PM


All times are GMT +1. The time now is 12:47 PM.

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"