macro delete rows <>1

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
 
S

Shasur

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
 
F

Forza MIlan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top