View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
CPower[_31_] CPower[_31_] is offline
external usenet poster
 
Posts: 1
Default Delete if blank...

Hi all,

I am trying to delete an entire row if a cell in col F is blank and i
the corresponding cell in col E does NOT equal a certain list of names
Here are two different pieces of code that i have been trying to use bu
they don't seem to work. The second piece of code worked in anothe
worksheet using different cols.

If col F has a blank cell, this piece of code deletes the entire row n
matter what name is in col E:

Dim i, j As Long
j = Range("E65536").End(xlUp).Row
For i = j To 1 Step -1
If Range("E" & i).Value < "Bertrandk" _
Or Range("E" & i).Value < "christianp" _
Or Range("E" & i).Value < "dennisk" _
Or Range("E" & i).Value < "josephl" _
Or Range("E" & i).Value < "mariaf" _
Or Range("E" & i).Value < "vincentp" Then
If Range("F" & i).Value = "" Then
Rows(i).EntireRow.Delete
End If
End If
Next i



This piece of code does not delete or keep any row if it has a blan
cell in col F:

Dim c As Range

For Each c In Range("F:F").SpecialCells(xlCellTypeBlanks)
If c.Offset(0, -1) = "Bertrandk" _
Or c.Offset(0, -1) = "christianp" _
Or c.Offset(0, -1) = "dennisk" _
Or c.Offset(0, -1) = "josephl" _
Or c.Offset(0, -1) = "mariaf" _
Or c.Offset(0, -1) = "vincentp" Then
'do nothing
Else
c.Offset(0, 45).Value = 1
End If
Next c

On Error Resume Next 'ignore error
Selection.Offset(0
45).SpecialCells(xlCellTypeConstants).EntireRow.De lete


Could someone please enlighten me as to what i am doin wrong in eithe
of these pieces of code??

Thanks,
Cathal

--
Message posted from http://www.ExcelForum.com