Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Macro deleting row if duplicates found

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
theiliad2000x@yahoo.com - 31 May 2008 17:13 GMT
Is there a macro whereby if I have a list, all in one column, but
different rows:

Column A:

Row 1: Alpha Beta Gamma
Row 2: Alpha Alpha Alpha
Row 3: Beta Gamma Gamma
Row 4: Gamma Gamma Alpha

If I wanted to delete all rows in MS Excel that have the word "Beta"
in it, I should be left with:

Alpha Alpha Alpha
Gamma Gamma Alpha

Thanks.
Dave Peterson - 31 May 2008 17:34 GMT
I would add a header row, then do data|filter|autofilter on that column.

Use the dropdown arrow
Contains
beta

And then delete the visible rows

Then remove the autofilter.

> Is there a macro whereby if I have a list, all in one column, but
> different rows:
[quoted text clipped - 13 lines]
>
> Thanks.

Signature

Dave Peterson

theiliad2000x@yahoo.com - 31 May 2008 18:16 GMT
> I would add a header row, then do data|filter|autofilter on that column.
>
[quoted text clipped - 31 lines]
>
> - Show quoted text -

Dave,

Thanks, that sounds like a good idea, especially for a short list.
But my lists are always more than a thousand rows, and, unless I'm
missing a step here, it would take a very long time to delete all
those rows manually, that's why I was trying to find an automated
system.
Gord Dibben - 31 May 2008 18:32 GMT
"Delete the visible rows".

To select visible rows hit F5>Special>Visible rows only

Edit>Delete will delete all at once.

Gord Dibben  MS Excel MVP

>> I would add a header row, then do data|filter|autofilter on that column.
>>
[quoted text clipped - 39 lines]
>those rows manually, that's why I was trying to find an automated
>system.
Tim Zych - 31 May 2008 18:40 GMT
Sub DeleteBeta()
   Dim rng As Range, cell As Range, rngToDelete As Range
   Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
   For Each cell In rng.Cells
       If UCase(cell.Value) Like "*BETA*" Then
           If rngToDelete Is Nothing Then
               Set rngToDelete = cell
           Else
               Set rngToDelete = Union(rngToDelete, cell)
           End If
       End If
   Next
   If Not rngToDelete Is Nothing Then
       rngToDelete.EntireRow.Delete
   End If
End Sub

Signature

Tim Zych
www.higherdata.com
Compare data in workbooks and find differences with Workbook Compare
A free, powerful, flexible Excel utility

> Is there a macro whereby if I have a list, all in one column, but
> different rows:
[quoted text clipped - 13 lines]
>
> Thanks.
theiliad2000x@yahoo.com - 31 May 2008 20:32 GMT
Thank you very much everyone for helping me out, I appreciate the
useful advise, everything has worked out.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.