PC Review


Reply
Thread Tools Rate Thread

delete the non blank rows

 
 
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 cells 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
Guest
Posts: n/a
 
      18th Nov 2008
Sub Remove_Blank_Rows()
'Highlight range of cells on wksheet;this deletes
'all rows with cells exactly matching cases
Dim rng As Range
Dim Cell, RowArray As Range
Set rng = ActiveSheet.Range(Cells(2, "C"), Cells(Rows.Count, "C").End(xlUp))
For Each Cell In rng
Select Case Cell
Case Is = "" '
If RowArray Is Nothing Then
Set RowArray = Cell.EntireRow
Else
Set RowArray = Union(RowArray, Cell.EntireRow)
End If
End Select
Next Cell
On Error Resume Next
RowArray.delete
Err.Clear
End Sub

"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 cells 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
Guest
Posts: n/a
 
      18th Nov 2008
Sorry change this line Case Is = "" with this Case Is <> ""

"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 cells 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 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
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 blank row only if 2 consecutive blank rows =?Utf-8?B?QW15?= Microsoft Excel Programming 2 21st Oct 2004 05:24 PM
delete blank rows steve Microsoft Excel Worksheet Functions 1 3rd Oct 2003 08:28 PM
Delete blank rows Andy B Microsoft Excel Misc 1 2nd Oct 2003 09:34 AM


Features
 

Advertising
 

Newsgroups
 


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