Hello Everyone,
I am new to this forum and I tried to find a similar thread, but couldn't find one addressing my issue exactly.
I am using Excel 2003 and I have a worksheet that contains about 3000 rows and is updated daily.
I filter the worksheet based on different criteria and save a number of smaller files.
The problem I have here is the following:
In columns N and O, I have different values. What I have to do there is to find in both columns cells that contain 2 certain values and delete all the rest of the rows. So, for example if the values are "123" and "234" I need to find all cells in columns N and O that contain those values and delete the rest of the rows. SO, I need to remove rows where in both columns the value is different than the two above.
Maybe there is a better way to do this but at the moment I am trying to do this using the following code (I am starting to wonder if it is logically correct):
<CODE>
</CODE>
<CODE></CODE>
When trying to run this code, I receive a 'Type Mismatch" error.
I would really appreciate any help on this, or a suggestion how to perform this filtering in another way.
Thanks very much!
Best regards,
Momchil
I am new to this forum and I tried to find a similar thread, but couldn't find one addressing my issue exactly.
I am using Excel 2003 and I have a worksheet that contains about 3000 rows and is updated daily.
I filter the worksheet based on different criteria and save a number of smaller files.
The problem I have here is the following:
In columns N and O, I have different values. What I have to do there is to find in both columns cells that contain 2 certain values and delete all the rest of the rows. So, for example if the values are "123" and "234" I need to find all cells in columns N and O that contain those values and delete the rest of the rows. SO, I need to remove rows where in both columns the value is different than the two above.
Maybe there is a better way to do this but at the moment I am trying to do this using the following code (I am starting to wonder if it is logically correct):
<CODE>
</CODE>
Code:
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, "N").Value <> "123" Or _
Cells(i, "N").Value <> "234" And _
Cells(i, "O").Value <> "123" Or _
Cells(i, "O").Value <> "234" Then
Rows(i).EntireRow.Delete
End If
Next i
When trying to run this code, I receive a 'Type Mismatch" error.
I would really appreciate any help on this, or a suggestion how to perform this filtering in another way.
Thanks very much!
Best regards,
Momchil