PC Review


Reply
Thread Tools Rate Thread

how can I delete rows based on column value

 
 
mike
Guest
Posts: n/a
 
      24th Jun 2008
How can I delete certain rows of my worksheet that has a specific value in a
specific column. For example, delete all rows that have a value of '0' in
column 'C'??

Mike
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      24th Jun 2008
apply an autofilter to column C, filter on 0, and then just delete the
visible rows.

--
__________________________________
HTH

Bob

"mike" <(E-Mail Removed)> wrote in message
news:34FA01A9-8AA5-477A-8859-(E-Mail Removed)...
> How can I delete certain rows of my worksheet that has a specific value in
> a
> specific column. For example, delete all rows that have a value of '0' in
> column 'C'??
>
> Mike



 
Reply With Quote
 
StumpedAgain
Guest
Posts: n/a
 
      24th Jun 2008
The following works for one "0". You can build a loop around this and use
FindNext() to locate others.

Option Explicit
Sub find()

Dim c As Range
Set c = Range("C:C").find(What:="0")
Rows(c.Row).Delete

End Sub


"mike" wrote:

> How can I delete certain rows of my worksheet that has a specific value in a
> specific column. For example, delete all rows that have a value of '0' in
> column 'C'??
>
> Mike

 
Reply With Quote
 
StumpedAgain
Guest
Posts: n/a
 
      24th Jun 2008
PS. I like bob's idea better (just refreshed the page)

"mike" wrote:

> How can I delete certain rows of my worksheet that has a specific value in a
> specific column. For example, delete all rows that have a value of '0' in
> column 'C'??
>
> Mike

 
Reply With Quote
 
mike
Guest
Posts: n/a
 
      24th Jun 2008
That still deleted everything.



"StumpedAgain" wrote:

> PS. I like bob's idea better (just refreshed the page)
>
> "mike" wrote:
>
> > How can I delete certain rows of my worksheet that has a specific value in a
> > specific column. For example, delete all rows that have a value of '0' in
> > column 'C'??
> >
> > Mike

 
Reply With Quote
 
mike
Guest
Posts: n/a
 
      24th Jun 2008
I gues I could just sort and delete, that's even simpler. I don't really need
to preserve thorder.

"StumpedAgain" wrote:

> PS. I like bob's idea better (just refreshed the page)
>
> "mike" wrote:
>
> > How can I delete certain rows of my worksheet that has a specific value in a
> > specific column. For example, delete all rows that have a value of '0' in
> > column 'C'??
> >
> > Mike

 
Reply With Quote
 
RyanH
Guest
Posts: n/a
 
      24th Jun 2008
This shoudl do the trick.

Sub DeleteRows()

Dim i As Long
Dim LastRow As Long

LastRow = Sheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row

For i = LastRow To 1 Step -1
If Range("C" & i) = 0 Then
Range("C" & i).EntireRow.Delete
End If
Next i

End Sub

--
Cheers,
Ryan


"mike" wrote:

> How can I delete certain rows of my worksheet that has a specific value in a
> specific column. For example, delete all rows that have a value of '0' in
> column 'C'??
>
> Mike

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      24th Jun 2008
Sub DeleteRows_With_Zero()
FindString = "0"
Set b = Range("C:C").Find(what:=FindString, lookat:=xlWhole)
While Not (b Is Nothing)
b.entirerow.Delete
Set b = Range("C:C").Find(what:=FindString, lookat:=xlWhole)
Wend
End Sub


Gord Dibben MS Excel MVP

On Tue, 24 Jun 2008 13:44:00 -0700, mike <(E-Mail Removed)> wrote:

>How can I delete certain rows of my worksheet that has a specific value in a
>specific column. For example, delete all rows that have a value of '0' in
>column 'C'??
>
>Mike


 
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
Code help, delete rows based on column criteria =?Utf-8?B?U3RvdXQ=?= Microsoft Excel Misc 2 20th Mar 2007 01:17 PM
Convert columns to rows: create duplicate rows based on column val =?Utf-8?B?Q2FycmllUg==?= Microsoft Access 3 30th Aug 2006 07:07 PM
how to delete rows based on duplicate information in a column albertpinto Microsoft Excel Discussion 5 29th May 2006 02:20 PM
Delete Rows based on criteria in Column A (not working) Mslady Microsoft Excel Programming 2 29th Oct 2005 01:27 AM
VBA Sub to delete rows based on a Column Value DoctorV Microsoft Excel Discussion 2 23rd Jul 2004 09:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:51 PM.