Deleting rows

  • Thread starter Thread starter gti_jobert
  • Start date Start date
G

gti_jobert

Hi all,

Trying to loop through entire woorksheet and then based on cell
criteria (empty or not) delete the entire row. I have the following
implemented....but dows not work;


Code:
--------------------

Private Sub cmdFilter_Click()

'Copy Data Sheet & Paste Data onto a New Sheet
Cells.Select
Selection.Copy
Worksheets.Add
ActiveSheet.Paste
ActiveSheet.Rows(1).Select
Selection.Delete

'Delete rows that are not needed
strMySheet = ActiveSheet.Name
Sheets(strMySheet).Select


Sheets(strMySheet).Cells(1, 1).Select

i = 1
Do
If (Cells(i, 4).Value = "") And (Cells(i, 5).Value <> "") Then
Sheets(strMySheet).Cells(i, 1).Select
Selection.EntireRow.Delete
End If
i = i + 1
Loop Until (Sheets(strMySheet).Cells(i, 1).Value <> "")

End Sub
 
Hi GTI,

Try:

'=============>>
Public Sub Tester()
On Error Resume Next
ActiveSheet.Columns(1). _
SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0
End Sub
'<<=============
 
Hi,

that would work, but i need to base it other cirteria as well - no
just the cells i suggested in my first post
 
Then give all the details.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Hello,

I have a sheet containing masses of data. I want all rows to be deleted
IF (Col 4 isnull And Col 5 isNotNull And Col 9 isnull And Col 10
isNotNull)

I hope this helps.....I have been trying a few variations of code but
dont seem to understand what its doing;


Code:
--------------------

i = 2
Do
ActiveSheet.Rows(i).Select
If Cells(i, 4).Value = "" Then
ActiveSheet.Rows(i - 1).Select
MsgBox Cells(i, 4).Value
Selection.Delete
End If
i = i + 1
Loop Until i = 40
 
I think I have sorted it now bob...did the following;


Code:
--------------------

i = 1
Do
If ActiveSheet.Cells(i, 4).Value = "" Then
ActiveSheet.Rows(i).Select
'MsgBox ActiveSheet.Cells(i, 1).Value
Selection.Delete
i = i - 1
End If
i = i + 1
Loop Until ActiveSheet.Cells(i, 1).Value = ""
 
Hi all,
I have no experience whatsoever with VBA. Can you please tell me what
will be the code to delete all rows which do not have numerical values
in the cells in first column (the ones I want to get rid of are either
empty or contain text)?
Thank you,
emil
 
Back
Top