Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Deleting rows containing zeros

I am importing a variable amount (10,000+) rows of source data into an Excel
2002 worksheet. Many of the rows will contain zero in column B (total
quantity) or zero in column C (total cost) which are not required. How can I
automatically delete rows that contain zeros in BOTH columns?
The intention is then to rank the remaining data.

Thanks in anticipation.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Deleting rows containing zeros

There is no automatic way to delete rows. In the end that will be a process
of steps of some sort. If you are getting 10,000 + rows of source data then I
assume that it is coming from a data base of some sort. How about modifying
the query to exclude those records. If that is not possible then probably the
easiest would just to be to sort the data pulling the zeros to the top and
then delete those rows. Other possibilites would be to use an auto filter or
a pivot table...
--
HTH...

Jim Thomlinson


"Grey Old Man" wrote:

I am importing a variable amount (10,000+) rows of source data into an Excel
2002 worksheet. Many of the rows will contain zero in column B (total
quantity) or zero in column C (total cost) which are not required. How can I
automatically delete rows that contain zeros in BOTH columns?
The intention is then to rank the remaining data.

Thanks in anticipation.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Deleting rows containing zeros

Hi,

How about a macro. Alt+F11 to open VB editor. Right click 'ThisWorkbook' and
insert module and paste the code in. Change the sheet to the correct one and
run the code. I never actually bothered to distinguish between blank cells
and zero because in this application I don't think it mmatters.

Sub delete_Me()
Dim CopyRange As Range
Dim LastRow As Long
Set sht = Sheets("Sheet1") ' change to suit
LastRow = sht.Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set MyRange = sht.Range("B1:B" & LastRow)
For Each c In MyRange
If c.Value = 0 And c.Offset(, 1).Value = 0 Then
If CopyRange Is Nothing Then
Set CopyRange = c.EntireRow
Else
Set CopyRange = Union(CopyRange, c.EntireRow)
End If
End If
Next
If Not CopyRange Is Nothing Then
CopyRange.Delete
End If
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Grey Old Man" wrote:

I am importing a variable amount (10,000+) rows of source data into an Excel
2002 worksheet. Many of the rows will contain zero in column B (total
quantity) or zero in column C (total cost) which are not required. How can I
automatically delete rows that contain zeros in BOTH columns?
The intention is then to rank the remaining data.

Thanks in anticipation.

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 (with zeros) with a macro ToddS Excel Worksheet Functions 4 April 7th 09 09:53 PM
Deleting rows (with zeros) with a macro Scott R Excel Worksheet Functions 7 April 3rd 09 06:13 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
How to prevent Excel from deleting leading zeros? ljCharlie Excel Discussion (Misc queries) 1 October 31st 05 10:04 PM
Deleting Lead Zeros Hardip Excel Worksheet Functions 4 August 31st 05 01:37 PM


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