View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robert Bruce[_2_] Robert Bruce[_2_] is offline
external usenet poster
 
Posts: 108
Default If Or not working

Roedd <<Kevin wedi ysgrifennu:

I get a type mismatch error on the code below at the IF line. Im
trying to pick out the rows that start with a certain text and delete
all of the other rows to shift cells up. I have it working now by
selecting each cell and evaluating it but it takes a long time to go
through 1 or 2 thousand lines. I'm trying to speed it up a little.
EX. If the first cell in each row starts with One, Two, Three, Four
and Five, I just want the One and Two rows to stay. Can anyone offer
any suggestions?
======================================
For Each c In MyRange
If Left(ActiveCell, 3) < "One" Or "Two" Then
ActiveCell.EntireRow.Delete
End If
Next
======================================
Thanks,
Kevin


Each clause of the or needs to be a complete test:

If Left(ActiveCell, 3) < "One" Or Left(ActiveCell, 3) < "Two" Then

However, I think you really need an AND!

--
Rob

http://www.asta51.dsl.pipex.com/webcam/

This message is copyright Robert Bruce and intended
for distribution only via NNTP.
Dissemination via third party Web forums with the
exception of Google Groups and Microsoft Communities
is strictly prohibited and may result in legal action.