A
Ann Scharpf
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
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