Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP...For Each...Loop is not working right

Status
Not open for further replies.

Nick34

Technical User
Oct 16, 2003
50
US
Is there any reason why this code would not delete rows that have empty cells in the 3rd column after being run only once???

It must be run about 6 or 7 times before all of the rows with empty cells are deleted.

Sub RemoveBlanks()

Dim oCell As Object

Worksheets("SO2REMOVAL1").Select

Application.Goto "R2C3"

Range(Selection, Selection.End(xlDown)).Select

For Each oCell In Selection

If oCell = "" Then
'Debug.Print oCell.Offset(0, -1).Value
Rows(RowIndex:=(oCell.Row)).Delete
End If

Next oCell

End Sub

 
You are actually in the wrong forum. This is an Access forum, but as for your code, I would change the if statement to this:

If len(oCell) = 0

you might also want to check for nulls since they are handled differently.
 
Sorry. I'm so used to having problems with Access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top