PC Review


Reply
Thread Tools Rate Thread

Delete rows with data

 
 
=?Utf-8?B?QW15THlubjkxNTY=?=
Guest
Posts: n/a
 
      10th Jul 2007
Hello,

I have seen several variations on this, but can't get them to work on my
spreadsheet. I have several rows of data(around 600, but it will change each
time). How can I delete all rows that contain any data in column J? When I
did the recording macro, it did this:

Selection.AutoFilter Field: =10, Criteria1:="<>"
ActiveWindow.SmallScroll Down:=-12
Selection.EntireRow.Delete

This works for my original data, but when I tested it on prior data, it
didn't work.

My VBA knowledge is very basic, if you can't already tell. :-)
Any help will be appreciated.

Thanks!
Amy
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      10th Jul 2007
One way:-

Sub mission()
With ActiveSheet
lastrow = .Cells(.Rows.Count, "J").End(xlUp).Row
End With
For x = lastrow To 1 Step -1
Cells(x, 10).Select
If ActiveCell.Value <> "" Then
Selection.EntireRow.Delete
End If
Next
End Sub


Mike

"AmyLynn9156" wrote:

> Hello,
>
> I have seen several variations on this, but can't get them to work on my
> spreadsheet. I have several rows of data(around 600, but it will change each
> time). How can I delete all rows that contain any data in column J? When I
> did the recording macro, it did this:
>
> Selection.AutoFilter Field: =10, Criteria1:="<>"
> ActiveWindow.SmallScroll Down:=-12
> Selection.EntireRow.Delete
>
> This works for my original data, but when I tested it on prior data, it
> didn't work.
>
> My VBA knowledge is very basic, if you can't already tell. :-)
> Any help will be appreciated.
>
> Thanks!
> Amy

 
Reply With Quote
 
=?Utf-8?B?QW15THlubjkxNTY=?=
Guest
Posts: n/a
 
      10th Jul 2007
Thanks! That worked. Is there any way to make this move faster? It took a
good 5 minutes for this to delete all of the rows.

"Mike H" wrote:

> One way:-
>
> Sub mission()
> With ActiveSheet
> lastrow = .Cells(.Rows.Count, "J").End(xlUp).Row
> End With
> For x = lastrow To 1 Step -1
> Cells(x, 10).Select
> If ActiveCell.Value <> "" Then
> Selection.EntireRow.Delete
> End If
> Next
> End Sub
>
>
> Mike
>
> "AmyLynn9156" wrote:
>
> > Hello,
> >
> > I have seen several variations on this, but can't get them to work on my
> > spreadsheet. I have several rows of data(around 600, but it will change each
> > time). How can I delete all rows that contain any data in column J? When I
> > did the recording macro, it did this:
> >
> > Selection.AutoFilter Field: =10, Criteria1:="<>"
> > ActiveWindow.SmallScroll Down:=-12
> > Selection.EntireRow.Delete
> >
> > This works for my original data, but when I tested it on prior data, it
> > didn't work.
> >
> > My VBA knowledge is very basic, if you can't already tell. :-)
> > Any help will be appreciated.
> >
> > Thanks!
> > Amy

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      10th Jul 2007
Check out this page for a few ways
http://www.rondebruin.nl/delete.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"AmyLynn9156" <(E-Mail Removed)> wrote in message news:0100382D-8232-4016-B037-(E-Mail Removed)...
> Thanks! That worked. Is there any way to make this move faster? It took a
> good 5 minutes for this to delete all of the rows.
>
> "Mike H" wrote:
>
>> One way:-
>>
>> Sub mission()
>> With ActiveSheet
>> lastrow = .Cells(.Rows.Count, "J").End(xlUp).Row
>> End With
>> For x = lastrow To 1 Step -1
>> Cells(x, 10).Select
>> If ActiveCell.Value <> "" Then
>> Selection.EntireRow.Delete
>> End If
>> Next
>> End Sub
>>
>>
>> Mike
>>
>> "AmyLynn9156" wrote:
>>
>> > Hello,
>> >
>> > I have seen several variations on this, but can't get them to work on my
>> > spreadsheet. I have several rows of data(around 600, but it will change each
>> > time). How can I delete all rows that contain any data in column J? When I
>> > did the recording macro, it did this:
>> >
>> > Selection.AutoFilter Field: =10, Criteria1:="<>"
>> > ActiveWindow.SmallScroll Down:=-12
>> > Selection.EntireRow.Delete
>> >
>> > This works for my original data, but when I tested it on prior data, it
>> > didn't work.
>> >
>> > My VBA knowledge is very basic, if you can't already tell. :-)
>> > Any help will be appreciated.
>> >
>> > Thanks!
>> > Amy

 
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 rows if data is either aileen Microsoft Excel Programming 3 8th Oct 2008 08:26 PM
How do I delete blank rows (rows alternate data, blank, data, etc =?Utf-8?B?bmNvY2hyYXg=?= Microsoft Excel Misc 2 27th Jun 2007 04:40 AM
Delete rows with no data =?Utf-8?B?TWluZGll?= Microsoft Excel Setup 1 30th Nov 2005 09:24 PM
Delete rows if certain data in rows scain2004 Microsoft Excel Programming 1 11th Mar 2004 10:39 PM
Delete certain rows of data... RMJ Microsoft Excel Programming 3 26th Jan 2004 08:30 AM


Features
 

Advertising
 

Newsgroups
 


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