Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Deleting Rows with Sum of "0" in 4 columns

A B C D E
Product Sub Sub Sub Sub
Code Code Code Code Code
-1 -2 -3
-4
111 0 0 0 25
222 0 0 0
0
333 5 1 0
0
444 0 0 0
0
555 1 0 0
0
666 0 0 1
0

In the above example I have:
25 of Product Code 111-4
0 of any Product Code 222
5 of Product Code 333-1 and 1 of Product Code 333-2
0 of any Product code 444
1 of Product Code 555-1 and 1 of Product Code 666-3.

Each box contains a formula that refers to other sheets. It is not blank,
but the result of the formula is zero.

I would like to delete the rows with the 222's and the 444's because the sum
of columns B thru E is zero.

Is there a way to do this via a Macro.
Thanks,
Mike



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleting Rows with Sum of "0" in 4 columns

Can't tell exactly how your data is laid out, but

assuming delete rows where sum of B:E is zero:

Sub TestDeletion()
Dim lastrow as Long, i as Long
set lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

Test this on a copy of your sheet.

--
Regards,
Tom Ogilvy


"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
A B C D

E
Product Sub Sub Sub Sub
Code Code Code Code Code
-1 -2 -3
-4
111 0 0 0

25
222 0 0 0
0
333 5 1 0
0
444 0 0 0
0
555 1 0 0
0
666 0 0 1
0

In the above example I have:
25 of Product Code 111-4
0 of any Product Code 222
5 of Product Code 333-1 and 1 of Product Code 333-2
0 of any Product code 444
1 of Product Code 555-1 and 1 of Product Code 666-3.

Each box contains a formula that refers to other sheets. It is not blank,
but the result of the formula is zero.

I would like to delete the rows with the 222's and the 444's because the

sum
of columns B thru E is zero.

Is there a way to do this via a Macro.
Thanks,
Mike





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Deleting Rows with Sum of "0" in 4 columns

Sorry Tom,
I get Compile Error:
Object required
and "lastrow =" is highlighted.

You DO understand the concept, though,
I want to remove rows where the sum of B:E is zero.
Thanks,
Mike

"Tom Ogilvy" wrote in message ...
Can't tell exactly how your data is laid out, but

assuming delete rows where sum of B:E is zero:

Sub TestDeletion()
Dim lastrow as Long, i as Long
set lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

Test this on a copy of your sheet.

--
Regards,
Tom Ogilvy


"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
A B C D

E
Product Sub Sub Sub Sub
Code Code Code Code Code
-1 -2 -3
-4
111 0 0 0

25
222 0 0 0
0
333 5 1 0
0
444 0 0 0
0
555 1 0 0
0
666 0 0 1
0

In the above example I have:
25 of Product Code 111-4
0 of any Product Code 222
5 of Product Code 333-1 and 1 of Product Code 333-2
0 of any Product code 444
1 of Product Code 555-1 and 1 of Product Code 666-3.

Each box contains a formula that refers to other sheets. It is not blank,
but the result of the formula is zero.

I would like to delete the rows with the 222's and the 444's because the

sum
of columns B thru E is zero.

Is there a way to do this via a Macro.
Thanks,
Mike





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleting Rows with Sum of "0" in 4 columns

I have a bad habit of using

Set lastrow =,

The set should be removed:

Sub TestDeletion()
Dim lastrow as Long, i as Long
lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
Sorry Tom,
I get Compile Error:
Object required
and "lastrow =" is highlighted.

You DO understand the concept, though,
I want to remove rows where the sum of B:E is zero.
Thanks,
Mike

"Tom Ogilvy" wrote in message
...
Can't tell exactly how your data is laid out, but

assuming delete rows where sum of B:E is zero:

Sub TestDeletion()
Dim lastrow as Long, i as Long
set lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

Test this on a copy of your sheet.

--
Regards,
Tom Ogilvy


"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
A B C D

E
Product Sub Sub Sub Sub
Code Code Code Code Code
-1 -2 -3
-4
111 0 0 0

25
222 0 0 0
0
333 5 1 0
0
444 0 0 0
0
555 1 0 0
0
666 0 0 1
0

In the above example I have:
25 of Product Code 111-4
0 of any Product Code 222
5 of Product Code 333-1 and 1 of Product Code 333-2
0 of any Product code 444
1 of Product Code 555-1 and 1 of Product Code 666-3.

Each box contains a formula that refers to other sheets. It is not blank,
but the result of the formula is zero.

I would like to delete the rows with the 222's and the 444's because the

sum
of columns B thru E is zero.

Is there a way to do this via a Macro.
Thanks,
Mike






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleting Rows with Sum of "0" in 4 columns

Whew, bad day: -- as Ron said

Sub TestDeletion()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 2).End(xlUp).Row
For i = lastrow To 2 Step -1
If Application.Sum(Cells(i, 2).Resize(1, 4)) = 0 Then
Rows(i).Delete
End If
Next
End Sub


I tested that one and it worked.

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
I have a bad habit of using

Set lastrow =,

The set should be removed:

Sub TestDeletion()
Dim lastrow as Long, i as Long
lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
Sorry Tom,
I get Compile Error:
Object required
and "lastrow =" is highlighted.

You DO understand the concept, though,
I want to remove rows where the sum of B:E is zero.
Thanks,
Mike

"Tom Ogilvy" wrote in message
...
Can't tell exactly how your data is laid out, but

assuming delete rows where sum of B:E is zero:

Sub TestDeletion()
Dim lastrow as Long, i as Long
set lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

Test this on a copy of your sheet.

--
Regards,
Tom Ogilvy


"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
A B C D

E
Product Sub Sub Sub Sub
Code Code Code Code Code
-1 -2 -3
-4
111 0 0 0

25
222 0 0 0
0
333 5 1 0
0
444 0 0 0
0
555 1 0 0
0
666 0 0 1
0

In the above example I have:
25 of Product Code 111-4
0 of any Product Code 222
5 of Product Code 333-1 and 1 of Product Code 333-2
0 of any Product code 444
1 of Product Code 555-1 and 1 of Product Code 666-3.

Each box contains a formula that refers to other sheets. It is not

blank,
but the result of the formula is zero.

I would like to delete the rows with the 222's and the 444's because the

sum
of columns B thru E is zero.

Is there a way to do this via a Macro.
Thanks,
Mike










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Deleting Rows with Sum of "0" in 4 columns

Hi Tom

Whew, bad day

Glad I am not the only one<vbg


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Tom Ogilvy" wrote in message ...
Whew, bad day: -- as Ron said

Sub TestDeletion()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 2).End(xlUp).Row
For i = lastrow To 2 Step -1
If Application.Sum(Cells(i, 2).Resize(1, 4)) = 0 Then
Rows(i).Delete
End If
Next
End Sub


I tested that one and it worked.

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote in message
...
I have a bad habit of using

Set lastrow =,

The set should be removed:

Sub TestDeletion()
Dim lastrow as Long, i as Long
lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
Sorry Tom,
I get Compile Error:
Object required
and "lastrow =" is highlighted.

You DO understand the concept, though,
I want to remove rows where the sum of B:E is zero.
Thanks,
Mike

"Tom Ogilvy" wrote in message
...
Can't tell exactly how your data is laid out, but

assuming delete rows where sum of B:E is zero:

Sub TestDeletion()
Dim lastrow as Long, i as Long
set lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

Test this on a copy of your sheet.

--
Regards,
Tom Ogilvy


"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
A B C D

E
Product Sub Sub Sub Sub
Code Code Code Code Code
-1 -2 -3
-4
111 0 0 0

25
222 0 0 0
0
333 5 1 0
0
444 0 0 0
0
555 1 0 0
0
666 0 0 1
0

In the above example I have:
25 of Product Code 111-4
0 of any Product Code 222
5 of Product Code 333-1 and 1 of Product Code 333-2
0 of any Product code 444
1 of Product Code 555-1 and 1 of Product Code 666-3.

Each box contains a formula that refers to other sheets. It is not

blank,
but the result of the formula is zero.

I would like to delete the rows with the 222's and the 444's because the

sum
of columns B thru E is zero.

Is there a way to do this via a Macro.
Thanks,
Mike










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Deleting Rows with Sum of "0" in 4 columns

Tom,
Thanks! Works Beautifully!
I made your change and the "Application.Sum" Typo correction from Ron de
Bruin
and it cleaned up all the extraneous rows. I even halfway understand how it
works.
Thanks a lot!
Mike
"Tom Ogilvy" wrote in message
...
I have a bad habit of using

Set lastrow =,

The set should be removed:

Sub TestDeletion()
Dim lastrow as Long, i as Long
lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
Sorry Tom,
I get Compile Error:
Object required
and "lastrow =" is highlighted.

You DO understand the concept, though,
I want to remove rows where the sum of B:E is zero.
Thanks,
Mike

"Tom Ogilvy" wrote in message
...
Can't tell exactly how your data is laid out, but

assuming delete rows where sum of B:E is zero:

Sub TestDeletion()
Dim lastrow as Long, i as Long
set lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

Test this on a copy of your sheet.

--
Regards,
Tom Ogilvy


"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
A B C D

E
Product Sub Sub Sub Sub
Code Code Code Code Code
-1 -2 -3
-4
111 0 0 0

25
222 0 0 0
0
333 5 1 0
0
444 0 0 0
0
555 1 0 0
0
666 0 0 1
0

In the above example I have:
25 of Product Code 111-4
0 of any Product Code 222
5 of Product Code 333-1 and 1 of Product Code 333-2
0 of any Product code 444
1 of Product Code 555-1 and 1 of Product Code 666-3.

Each box contains a formula that refers to other sheets. It is not blank,
but the result of the formula is zero.

I would like to delete the rows with the 222's and the 444's because the

sum
of columns B thru E is zero.

Is there a way to do this via a Macro.
Thanks,
Mike







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Deleting Rows with Sum of "0" in 4 columns

For the OP

Typo alert

if application.Sub


Must be
if application.Sum

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Tom Ogilvy" wrote in message ...
Can't tell exactly how your data is laid out, but

assuming delete rows where sum of B:E is zero:

Sub TestDeletion()
Dim lastrow as Long, i as Long
set lastrow = cells(rows.count,2).End(xlup).row
for i = lastrow to 2 Step -1
if application.Sub(cells(i,2).Resize(1,4)) = 0 then
rows(i).Delete
end if
Next
End Sub

Test this on a copy of your sheet.

--
Regards,
Tom Ogilvy


"mike meyer" <mikejmeyer53atexcite.com wrote in message
...
A B C D

E
Product Sub Sub Sub Sub
Code Code Code Code Code
-1 -2 -3
-4
111 0 0 0

25
222 0 0 0
0
333 5 1 0
0
444 0 0 0
0
555 1 0 0
0
666 0 0 1
0

In the above example I have:
25 of Product Code 111-4
0 of any Product Code 222
5 of Product Code 333-1 and 1 of Product Code 333-2
0 of any Product code 444
1 of Product Code 555-1 and 1 of Product Code 666-3.

Each box contains a formula that refers to other sheets. It is not blank,
but the result of the formula is zero.

I would like to delete the rows with the 222's and the 444's because the

sum
of columns B thru E is zero.

Is there a way to do this via a Macro.
Thanks,
Mike







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
"Cross"-Auto filling: consecutive columns into rows AndreasW Excel Worksheet Functions 1 October 19th 09 01:46 PM
"Print titles must be contiguos and complete rows or columns?" Juan Diaz L Excel Discussion (Misc queries) 1 January 24th 08 04:47 PM
Make pivot table with multiple "data" fields in columns not rows? cdomby Excel Discussion (Misc queries) 1 January 15th 07 04:54 PM
Possible to "rotate" range of cells so columns are rows and vice versa? [email protected] New Users to Excel 3 January 5th 07 05:21 PM
Deleting "duplicate" rows mmednick Excel Discussion (Misc queries) 7 January 11th 06 08:22 PM


All times are GMT +1. The time now is 02:27 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"