Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro deleting row if duplicates found

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro deleting row if duplicates found

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.

wrote:

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro deleting row if duplicates found

On May 31, 11:34*am, Dave Peterson wrote:
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.





wrote:

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- Hide quoted text -

- 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.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Macro deleting row if duplicates found

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


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

wrote in message
...
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.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro deleting row if duplicates found

Thank you very much everyone for helping me out, I appreciate the
useful advise, everything has worked out.
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
Highlight rows if duplicates are found Pierre Excel Worksheet Functions 3 January 21st 10 03:03 PM
Copying or deleting row based on value found in other ws aintlifegrand79 Excel Programming 7 March 19th 08 10:32 AM
Remove duplicates found in master list Mike Excel Discussion (Misc queries) 2 December 13th 07 04:22 PM
Deleting a row containing a found cell Alan Excel Programming 6 May 16th 04 02:43 PM
Deleting Duplicates Charles Deng Excel Programming 3 May 12th 04 05:40 PM


All times are GMT +1. The time now is 05:20 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"