D
Dennis
Excel 2003
In the following VBA code, I am attempting to:
Delete Rows where there are blanks in column H
The code below SEEMS to work where there are NO blanks in Col H.
But when there ARE blanks in Col H, I still get an Error via MsgBox. Therefore, an Error occurred
triggering the MsgBox display. As a result the Row with a blank in Column H was not deleted.
Columns("A:W").AutoFilter Field:=8, Criteria1:="="
On Error Resume Next ' In case there no blanks
Selection = Range("H2", Selection.SpecialCells(xlCellTypeBlanks)).Select
If Err <> 0 Then
MsgBox "NOTE: Empty Rows were not located!"
Else
Selection.EntireRow.Delete
End If
On Error GoTo 0
Why does an error occur if, in fact, there is a blank in H?
Bottom line, I would like to be notified when there are no blank cells in Col H and have no rows
deleted. That said, if there are blanks in Column H, I do want those Rows deleted. I can not seem
to get both concepts to work correctly. Obviously, my logic is flawed.
Is it correct to assume that xlCellTypeBlanks are blanks in the Used Range?
TIA Dennis
In the following VBA code, I am attempting to:
Delete Rows where there are blanks in column H
The code below SEEMS to work where there are NO blanks in Col H.
But when there ARE blanks in Col H, I still get an Error via MsgBox. Therefore, an Error occurred
triggering the MsgBox display. As a result the Row with a blank in Column H was not deleted.
Columns("A:W").AutoFilter Field:=8, Criteria1:="="
On Error Resume Next ' In case there no blanks
Selection = Range("H2", Selection.SpecialCells(xlCellTypeBlanks)).Select
If Err <> 0 Then
MsgBox "NOTE: Empty Rows were not located!"
Else
Selection.EntireRow.Delete
End If
On Error GoTo 0
Why does an error occur if, in fact, there is a blank in H?
Bottom line, I would like to be notified when there are no blank cells in Col H and have no rows
deleted. That said, if there are blanks in Column H, I do want those Rows deleted. I can not seem
to get both concepts to work correctly. Obviously, my logic is flawed.
Is it correct to assume that xlCellTypeBlanks are blanks in the Used Range?
TIA Dennis