PC Review


Reply
Thread Tools Rate Thread

Delete duplicate cell

 
 
PointerMan
Guest
Posts: n/a
 
      3rd Mar 2009
I have a large spreadsheet that I need to clean up. My data is kept by row,
so some rows have the same information in two adjacent cells. An example is
below in rows 2 through 5.

1 DB A HF SR SCR PI
2 SAW DB SR DR DB DB
3 SAW DB SR DR DB DB
4 SAW DB SR DR DB DB
5 SAW DB SR DR DB DB

Is there a function that can automatically delete the 2nd duplicate cell
contents? I can delete them manually one at a time, but I'd like
to be able to clean up the entire sheet at once.


 
Reply With Quote
 
 
 
 
Shane Devenshire
Guest
Posts: n/a
 
      3rd Mar 2009
Hi,

In 2007 choose the command Data, Remove Duplicates

In 2003 enter this formula in G1

=IF(SUMPRODUCT(--(B2=B$1:B2),--(C2=C$1:C2),--(D2=D$12),--(E2=E$1:E2),--(F2=F$1:F2))>1,TRUE,0)

and copy it down as far as your data. Then highlight this column and press
F5, Special, Formulas, and uncheck all except Logicals, click OK. Press
Ctrl+- (control minus) and respond Entire Row.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"PointerMan" wrote:

> I have a large spreadsheet that I need to clean up. My data is kept by row,
> so some rows have the same information in two adjacent cells. An example is
> below in rows 2 through 5.
>
> 1 DB A HF SR SCR PI
> 2 SAW DB SR DR DB DB
> 3 SAW DB SR DR DB DB
> 4 SAW DB SR DR DB DB
> 5 SAW DB SR DR DB DB
>
> Is there a function that can automatically delete the 2nd duplicate cell
> contents? I can delete them manually one at a time, but I'd like
> to be able to clean up the entire sheet at once.
>
>

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      3rd Mar 2009
Hi,

If I understand correctly then your sample data should end up looking like
this

DB A HF SR SCR PI
SAW DB SR DR DB DB

Try this sub

Sub Please_Delete_me()
Dim y As Long
Dim x As Variant
Dim MyRange As Range
Set MyRange = Application.Intersect(ActiveSheet.UsedRange, _
ActiveSheet.Columns(ActiveCell.Column))
For y = MyRange.Rows.Count To 2 Step -1
x = MyRange.Cells(y, 1).Value
If Application.WorksheetFunction.CountIf(MyRange.Columns(1), x) > 1 Then
MyRange.Rows(y).EntireRow.Delete
End If
Next y
End Sub


Mike

"PointerMan" wrote:

> I have a large spreadsheet that I need to clean up. My data is kept by row,
> so some rows have the same information in two adjacent cells. An example is
> below in rows 2 through 5.
>
> 1 DB A HF SR SCR PI
> 2 SAW DB SR DR DB DB
> 3 SAW DB SR DR DB DB
> 4 SAW DB SR DR DB DB
> 5 SAW DB SR DR DB DB
>
> Is there a function that can automatically delete the 2nd duplicate cell
> contents? I can delete them manually one at a time, but I'd like
> to be able to clean up the entire sheet at once.
>
>

 
Reply With Quote
 
PointerMan
Guest
Posts: n/a
 
      3rd Mar 2009
I think I was too vague in what I was wanting. Let me try to explain better.
I'll use the following data set as my example:

1 SCR SAW DB DR DB DB PI PI DB
2 OSC OSC PI PI DR DR PI DB DR

I'd like to remove the duplicates (except for the OSC cells) that are next
to each other so that these two rows would look like this:

1 SCR SAW DB DR DB PI DB
2 OSC OSC PI DR PI DB DR

I need to keep the OSC cell duplicates intact, but everything else would
delete one of the two adjacent cells.



"Mike H" wrote:

> Hi,
>
> If I understand correctly then your sample data should end up looking like
> this
>
> DB A HF SR SCR PI
> SAW DB SR DR DB DB
>
> Try this sub
>
> Sub Please_Delete_me()
> Dim y As Long
> Dim x As Variant
> Dim MyRange As Range
> Set MyRange = Application.Intersect(ActiveSheet.UsedRange, _
> ActiveSheet.Columns(ActiveCell.Column))
> For y = MyRange.Rows.Count To 2 Step -1
> x = MyRange.Cells(y, 1).Value
> If Application.WorksheetFunction.CountIf(MyRange.Columns(1), x) > 1 Then
> MyRange.Rows(y).EntireRow.Delete
> End If
> Next y
> End Sub
>
>
> Mike
>
> "PointerMan" wrote:
>
> > I have a large spreadsheet that I need to clean up. My data is kept by row,
> > so some rows have the same information in two adjacent cells. An example is
> > below in rows 2 through 5.
> >
> > 1 DB A HF SR SCR PI
> > 2 SAW DB SR DR DB DB
> > 3 SAW DB SR DR DB DB
> > 4 SAW DB SR DR DB DB
> > 5 SAW DB SR DR DB DB
> >
> > Is there a function that can automatically delete the 2nd duplicate cell
> > contents? I can delete them manually one at a time, but I'd like
> > to be able to clean up the entire sheet at once.
> >
> >

 
Reply With Quote
 
driller
Guest
Posts: n/a
 
      4th Mar 2009
Pointerman,

just a hint ; i guess you may need to be more specific by having a subject
like *delete adjacent-duplicate inside each cell*

--
regards,

"PointerMan" wrote:

> I think I was too vague in what I was wanting. Let me try to explain better.
> I'll use the following data set as my example:
>
> 1 SCR SAW DB DR DB DB PI PI DB
> 2 OSC OSC PI PI DR DR PI DB DR
>
> I'd like to remove the duplicates (except for the OSC cells) that are next
> to each other so that these two rows would look like this:
>
> 1 SCR SAW DB DR DB PI DB
> 2 OSC OSC PI DR PI DB DR
>
> I need to keep the OSC cell duplicates intact, but everything else would
> delete one of the two adjacent cells.
>
>
>
> "Mike H" wrote:
>
> > Hi,
> >
> > If I understand correctly then your sample data should end up looking like
> > this
> >
> > DB A HF SR SCR PI
> > SAW DB SR DR DB DB
> >
> > Try this sub
> >
> > Sub Please_Delete_me()
> > Dim y As Long
> > Dim x As Variant
> > Dim MyRange As Range
> > Set MyRange = Application.Intersect(ActiveSheet.UsedRange, _
> > ActiveSheet.Columns(ActiveCell.Column))
> > For y = MyRange.Rows.Count To 2 Step -1
> > x = MyRange.Cells(y, 1).Value
> > If Application.WorksheetFunction.CountIf(MyRange.Columns(1), x) > 1 Then
> > MyRange.Rows(y).EntireRow.Delete
> > End If
> > Next y
> > End Sub
> >
> >
> > Mike
> >
> > "PointerMan" wrote:
> >
> > > I have a large spreadsheet that I need to clean up. My data is kept by row,
> > > so some rows have the same information in two adjacent cells. An example is
> > > below in rows 2 through 5.
> > >
> > > 1 DB A HF SR SCR PI
> > > 2 SAW DB SR DR DB DB
> > > 3 SAW DB SR DR DB DB
> > > 4 SAW DB SR DR DB DB
> > > 5 SAW DB SR DR DB DB
> > >
> > > Is there a function that can automatically delete the 2nd duplicate cell
> > > contents? I can delete them manually one at a time, but I'd like
> > > to be able to clean up the entire sheet at once.
> > >
> > >

 
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 codes in a cell Mat Microsoft Excel Misc 1 30th Jun 2009 02:52 AM
Delete a row where a cell in the previous row is a duplicate buscdr Microsoft Excel Programming 0 19th May 2009 10:18 PM
Macro to delete duplicate cell PointerMan Microsoft Excel Programming 1 4th Mar 2009 04:59 AM
delete duplicate data in the same cell elaine Microsoft Excel Programming 6 13th Dec 2006 04:55 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:24 PM.