Consulting

Results 1 to 9 of 9

Thread: Solved: Type mismatch error on If Not Range...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Feb 2013
    Posts
    18
    Location

    Solved: Type mismatch error on If Not Range...

    Can someone please help me with this? I've looked all around and I haven't found a reason why this code would not work. I keep getting a Type mismatch error on the "If Not Range..." row.

    [vba]
    Dim LR As Long, i As Long
    LR = Range("B" & Rows.Count).End(xlUp).Row
    For i = LR To 1 Step -1
    If Not Range("B" & i).Value Like "*Manor*" Then Rows(i).Delete
    Next i
    [/vba]

    This is part of a bigger macro but I can't get past this - the code should go through column B and any row where the cell in column B doesn't have the word "Manor" in it should be deleted.

    Thanks for your help! This is really irritating!


    Edit: I've added "IsError" in front of Range("B"...) and now my issue is that it is deleting everything. Even if the cell contains the word "Manor", it still deletes it.
    Last edited by freybe06; 02-26-2013 at 12:18 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •