PC Review


Reply
Thread Tools Rate Thread

Deleting rows when cell text reads "Research"

 
 
iashorty
Guest
Posts: n/a
 
      7th Nov 2008
I have a spreadsheet with 8,000 rows that I have performed some work on. In
column W "Research" and numbers appear. I have written in my macro so that
the data is sorted so that all the Research appears in the first rows.

How do I delete rows, as quickly as possible, that have Research in Column W?

I wrote the following Loop but it doesn't work and I am not sure that a Loop
is the quickest way to accomplish this. Column V is blank. I was trying to
establish a block of rows to be deleted and delete all at once.

Sub Macro1()
Range("V7").Select
ActiveCell.Formula = "1"
Range("W7").Select
X = ActiveCell.Row

Do While Cells(X, 23).Text = "Research"
X = X + 1
Loop

ActiveCell.Select
ActiveCell.Offset(-1, -1).Select
Selection.End(xlUp).Select
Selection.EntireRow.Delete Shift:=xlUp


End Sub

 
Reply With Quote
 
 
 
 
Michael
Guest
Posts: n/a
 
      7th Nov 2008
I have found that Autofilter is the fastest way to delete occurences of any
kind, please modify to suit your needs.

Range("W:W").AutoFilter Field:=1, Criteria1:="=Research", Operator:=xlAnd
Columns("W:W").SpecialCells(xlCellTypeVisible).EntireRow.Delete
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"iashorty" wrote:

> I have a spreadsheet with 8,000 rows that I have performed some work on. In
> column W "Research" and numbers appear. I have written in my macro so that
> the data is sorted so that all the Research appears in the first rows.
>
> How do I delete rows, as quickly as possible, that have Research in Column W?
>
> I wrote the following Loop but it doesn't work and I am not sure that a Loop
> is the quickest way to accomplish this. Column V is blank. I was trying to
> establish a block of rows to be deleted and delete all at once.
>
> Sub Macro1()
> Range("V7").Select
> ActiveCell.Formula = "1"
> Range("W7").Select
> X = ActiveCell.Row
>
> Do While Cells(X, 23).Text = "Research"
> X = X + 1
> Loop
>
> ActiveCell.Select
> ActiveCell.Offset(-1, -1).Select
> Selection.End(xlUp).Select
> Selection.EntireRow.Delete Shift:=xlUp
>
>
> End Sub
>

 
Reply With Quote
 
iashorty
Guest
Posts: n/a
 
      7th Nov 2008
Fantastic, thank you.

"Michael" wrote:

> I have found that Autofilter is the fastest way to delete occurences of any
> kind, please modify to suit your needs.
>
> Range("W:W").AutoFilter Field:=1, Criteria1:="=Research", Operator:=xlAnd
> Columns("W:W").SpecialCells(xlCellTypeVisible).EntireRow.Delete
> --
> If this posting was helpful, please click on the Yes button.
> Regards,
>
> Michael Arch.
>
>
>
>
> "iashorty" wrote:
>
> > I have a spreadsheet with 8,000 rows that I have performed some work on. In
> > column W "Research" and numbers appear. I have written in my macro so that
> > the data is sorted so that all the Research appears in the first rows.
> >
> > How do I delete rows, as quickly as possible, that have Research in Column W?
> >
> > I wrote the following Loop but it doesn't work and I am not sure that a Loop
> > is the quickest way to accomplish this. Column V is blank. I was trying to
> > establish a block of rows to be deleted and delete all at once.
> >
> > Sub Macro1()
> > Range("V7").Select
> > ActiveCell.Formula = "1"
> > Range("W7").Select
> > X = ActiveCell.Row
> >
> > Do While Cells(X, 23).Text = "Research"
> > X = X + 1
> > Loop
> >
> > ActiveCell.Select
> > ActiveCell.Offset(-1, -1).Select
> > Selection.End(xlUp).Select
> > Selection.EntireRow.Delete Shift:=xlUp
> >
> >
> > End Sub
> >

 
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
Deleting rows when cell has "#DIV/0!" error mattg Microsoft Excel Programming 2 19th Apr 2010 07:42 PM
Format a cell such that "#NAME?" reads/appears "N/A"? Fred Holmes Microsoft Excel Misc 2 18th Jun 2009 06:32 AM
Re: Format a cell such that "#NAME?" reads/appears "N/A"? T. Valko Microsoft Excel Misc 0 18th Jun 2009 03:08 AM
Bold all rows where a cell contains text "X" limpuiting@yahoo.com Microsoft Excel Programming 4 15th May 2007 04:21 AM
Delete rows that the first cell's text is "A" Greg :-) Microsoft Excel Discussion 2 27th Nov 2005 12:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:27 PM.