PC Review


Reply
Thread Tools Rate Thread

delete the non blank rows depending on Column

 
 
Harn88
Guest
Posts: n/a
 
      18th Nov 2008
Hello

I need some help with this please. I would like to create a Marco that will
help me delete the non blank rows depending on Column C. For example, a Marco
will delete everything except Row 2 Column C and Row 4 Column C. Since Column
C for those 2 rows is blank it will not delete.

A B C
1 meeting Yes 20
2 meeting Yes
3 meeting Yes 10
4 meeting Yes
5 meeting Yes 100

So after the Macro, it should look something like this

A B C
1 meeting Yes
2 meeting Yes

Thank you very much

Harn

 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      18th Nov 2008
Hi,

Right click your sheet tab, view code and paste this in and run it.

Sub stance()
Dim MyRange As Range
Dim DelRange As Range
Lastrow = Cells(Cells.Rows.Count, "C").End(xlUp).Row
Set MyRange = Range("C1:C" & Lastrow)
For Each C In MyRange
If Not IsEmpty(C) Then
If DelRange Is Nothing Then
Set DelRange = C.EntireRow
Else
Set DelRange = Union(DelRange, C.EntireRow)
End If
End If
Next
DelRange.delete
End Sub


Mike

"Harn88" wrote:

> Hello
>
> I need some help with this please. I would like to create a Marco that will
> help me delete the non blank rows depending on Column C. For example, a Marco
> will delete everything except Row 2 Column C and Row 4 Column C. Since Column
> C for those 2 rows is blank it will not delete.
>
> A B C
> 1 meeting Yes 20
> 2 meeting Yes
> 3 meeting Yes 10
> 4 meeting Yes
> 5 meeting Yes 100
>
> So after the Macro, it should look something like this
>
> A B C
> 1 meeting Yes
> 2 meeting Yes
>
> Thank you very much
>
> Harn
>

 
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 all rows where column A is blank Jodie Microsoft Excel Programming 6 14th Dec 2009 07:30 PM
Delete rows if column looks blank robyn_willson@hotmail.com Microsoft Excel Programming 4 18th Feb 2009 07:21 PM
Delete Blank Rows - specify column via dialog porter444 Microsoft Excel Programming 1 30th Nov 2007 04:45 PM
Delete Rows if any cell in Column H is blank but do not Delete Fir =?Utf-8?B?bWFuZmFyZWVk?= Microsoft Excel Programming 4 28th Sep 2007 05:20 PM
Delete entire rows where there is a blank in column A Chris Hankin Microsoft Excel Programming 7 11th Jun 2006 09:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:08 AM.