macro delete rows <>1

  • Thread starter Thread starter Forza MIlan
  • Start date Start date
F

Forza MIlan

Hi, i have a table with 10 columns and many rows. I want to delete all rows
which not contain "1" (doesn' t metter in wich column the "1" is). Any help
is appreciated
Sorry for my English
 
Hi

Can you check if the following is useful

Sub Delete_ONe_Row()

imaxrow = 10
For iRow = 1 To imaxrow
If iRow > imaxrow Then Exit Sub
For iCol = 1 To 10
If Cells(iRow, iCol) = 1 Then GoTo NoDelete
Next iCol
Rows(iRow).EntireRow.Delete
iRow = iRow - 1
imaxrow = imaxrow - 1
NoDelete:
Next iRow
End Sub

Cheers
Shasur
 
Thanks very much, it works:)

Shasur said:
Hi

Can you check if the following is useful

Sub Delete_ONe_Row()

imaxrow = 10
For iRow = 1 To imaxrow
If iRow > imaxrow Then Exit Sub
For iCol = 1 To 10
If Cells(iRow, iCol) = 1 Then GoTo NoDelete
Next iCol
Rows(iRow).EntireRow.Delete
iRow = iRow - 1
imaxrow = imaxrow - 1
NoDelete:
Next iRow
End Sub

Cheers
Shasur
 
Back
Top