Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 74
Default Deleting Rows in Excel 2003

Is there a macro that can delete the rows where the value in range a, range b
and range c is equal to zero? In my example below only row 6 would be
deleted.

Range A Range B Range C
Row 1 22 17 18
Row 2 9 10 24
Row 3 1 23 25
Row 4 0 0 26
Row 5 0 29 0
Row 6 0 0 0
Row 7 0 20 8
Row 8 30 28 7
Row 9 21 4 5
Row 10 6 3 14



  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Deleting Rows in Excel 2003

There could be.

But how about an alternative.

Add a new column (D) and put:
=countif(a1:c1,0)
and drag down

then apply data|Filter|autofilter
filter to show the 3's.
delete those visible rows
and delete that column.


Gilbert wrote:

Is there a macro that can delete the rows where the value in range a, range b
and range c is equal to zero? In my example below only row 6 would be
deleted.

Range A Range B Range C
Row 1 22 17 18
Row 2 9 10 24
Row 3 1 23 25
Row 4 0 0 26
Row 5 0 29 0
Row 6 0 0 0
Row 7 0 20 8
Row 8 30 28 7
Row 9 21 4 5
Row 10 6 3 14


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 74
Default Deleting Rows in Excel 2003

Thanks Dave, that's pretty clever.

"Dave Peterson" wrote:

There could be.

But how about an alternative.

Add a new column (D) and put:
=countif(a1:c1,0)
and drag down

then apply data|Filter|autofilter
filter to show the 3's.
delete those visible rows
and delete that column.


Gilbert wrote:

Is there a macro that can delete the rows where the value in range a, range b
and range c is equal to zero? In my example below only row 6 would be
deleted.

Range A Range B Range C
Row 1 22 17 18
Row 2 9 10 24
Row 3 1 23 25
Row 4 0 0 26
Row 5 0 29 0
Row 6 0 0 0
Row 7 0 20 8
Row 8 30 28 7
Row 9 21 4 5
Row 10 6 3 14


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Deleting Rows in Excel 2003

It's actually a very efficient way to deal with such a situation in many
cases. If you still want a Sub that would do specifically what you need for
some future use, or if this is an operation that either you or someone
unfamiliar with the process might 'need' to use, this should do the trick for
you. Copy and paste into a regular code module, will work on the sheet that
is active when the macro is executed.

Sub RemoveZeroValueRows()
'
'deletes rows with
'value of zero in columns
'A, B and C
'stops at first row with
'empty cells in those
'same columns.
'
Dim Roffset As Long

Range("A1").Select
Do Until IsEmpty(ActiveCell.Offset(Roffset, 0)) And _
IsEmpty(ActiveCell.Offset(Roffset, 1)) And _
IsEmpty(ActiveCell.Offset(Roffset, 2))
If ActiveCell.Offset(Roffset, 0) = 0 And _
ActiveCell.Offset(Roffset, 1) = 0 And _
ActiveCell.Offset(Roffset, 2) = 0 Then
Rows(ActiveCell.Offset(Roffset, 0).Row & ":" & _
ActiveCell.Offset(Roffset, 0).Row).Delete
Roffset = Roffset - 1
End If
Roffset = Roffset + 1
Loop

End Sub

"Gilbert" wrote:

Thanks Dave, that's pretty clever.

"Dave Peterson" wrote:

There could be.

But how about an alternative.

Add a new column (D) and put:
=countif(a1:c1,0)
and drag down

then apply data|Filter|autofilter
filter to show the 3's.
delete those visible rows
and delete that column.


Gilbert wrote:

Is there a macro that can delete the rows where the value in range a, range b
and range c is equal to zero? In my example below only row 6 would be
deleted.

Range A Range B Range C
Row 1 22 17 18
Row 2 9 10 24
Row 3 1 23 25
Row 4 0 0 26
Row 5 0 29 0
Row 6 0 0 0
Row 7 0 20 8
Row 8 30 28 7
Row 9 21 4 5
Row 10 6 3 14


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Rows in MS Excel MacK Excel Discussion (Misc queries) 9 July 30th 07 06:24 PM
Excel 2003; spreadsheet with filtering; deleting rows MHcoTech Excel Worksheet Functions 0 September 6th 06 01:33 AM
Excel links & inserting/deleting rows jd Excel Discussion (Misc queries) 2 February 4th 06 08:22 PM
Deleting rows in a macro in Excel THEFALLGUY Excel Discussion (Misc queries) 4 December 23rd 05 01:59 PM
Deleting Names in Excel 2003 steve_nelson Excel Discussion (Misc queries) 2 January 6th 05 12:56 PM


All times are GMT +1. The time now is 05:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"