LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Code to delete rows where cell value is zero

I am working in an Excel sheet where data is dumped from another system.
Many of the rows are extraneous - if the cell in the Current Hours column
(AB) contains a zero value, I'd like my macro to delete the row. Someone
here at my office knows more VBA than I do (which is very little) and we came
up with the following. It is NOT working correctly.

The current sheet of test data contains 575 rows. Of these, 24 have values
greater than zero in column AB. 551 rows contain a zero in AB. When I run
the macro, it does not seem to actually be using the values in AB to
determine what to delete. Depending on which cell is active when I start,
sometimes there are values 0 in AB, other times they are all = 0. I end up
with a different number of rows depending on where I start.

Here is the code of the macro. If anyone can tell me how to make the macro
look at the contents of the cells in column AB and delete when they contain
0, I would really appreciate it.

Thanks very much for your help.

Sub DelBlankCurHrsRows()
'
' DelBlankCurHrsRows Macro
' Macro recorded 10/18/2006 by Ann Scharpf
'
' Keyboard Shortcut: Ctrl+Shift+E
'
For Each c In Worksheets("Paste all employees' data
here").Range("AB2:AB41000")
If c.Value = "0" Then
Selection.EntireRow.Delete
End If
Next
End Sub




--
Ann Scharpf
 
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
VBA code to delete rows Secret Squirrel Excel Discussion (Misc queries) 3 January 21st 07 03:01 PM
Can this code be modified to delete rows? [email protected] Excel Programming 7 August 19th 06 11:58 AM
code to delete rows ianalexh Excel Discussion (Misc queries) 5 May 5th 05 10:46 AM
VB Code to Delete Unused Rows Ken[_18_] Excel Programming 2 October 1st 04 04:35 AM
Code to sort/delete rows doublef Excel Programming 2 June 22nd 04 12:14 AM


All times are GMT +1. The time now is 06:25 AM.

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"