Results 1 to 10 of 17

Thread: Exclude Contents From List :

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    12
    or:
    Code:
    Sub M_snb()
        sn = Range("B1:B3")
        sp = Filter(Filter(Filter(Application.Transpose(Range("A1:A1000")), sn(1, 1), False), sn(2, 1), False), sn(3, 1), False)
        Cells(1, 8).Resize(UBound(sp) + 1) = Application.Transpose(sp)
    End Sub
    or:
    Code:
    Sub M_snb_002()
        sn = Range("B1:B3")
        sp = Columns(1).SpecialCells(2)
        
        For j = 1 To UBound(sp)
            If (sp(j, 1) = sn(1, 1)) + (sp(j, 1) = sn(2, 1)) + (sp(j, 1) = sn(3, 1)) = 0 Then c00 = c00 & "_" & j
        Next
    
        sp = Application.Index(sp, Split(Mid(c00, 2), "_"), 1)
        Cells(1, 10).Resize(UBound(sp)) = Application.Transpose(sp)
    End Sub
    Does this amendment make any difference ?

    Code:
    Sub M_snb()
      sn = Range("B1:B3")
    
      For Each it In sn
        Columns(1).specialcells(2).Replace it, "", 1
      Next
    
      columns(1).specialcells(4).entirerow.delete
    End Sub
    Last edited by snb; 06-07-2013 at 12:26 PM.

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Persistence paid off!

    Your first rountine (the one with the three Filter and two Transpose calls) bounces between 0.02 and 0.03 seconds, mostly 0.02, so it matches the speed of my routine using only three active lines of code (eight lines of code less than mine)! Congratulations! I was a little surprised that those two Transpose calls did not slow things down more; actually, I would have thought the three nested Filter calls might have slowed thing down as well... obviously I would have been wrong. Again, well done. By the way, your other two attempts did not fair anywhere near as well... the second one taking about 0.14 seconds and the last on about 0.85 seconds. Oh, just for information sake, from the list of 10001 continent names, 2820 of them were being deleted.

Similar Threads

  1. Replies: 5
    Last Post: 01-12-2013, 02:49 AM
  2. Delete List Contain Matching from Second List
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 12
    Last Post: 10-07-2012, 07:18 PM
  3. Macro for Opening files and copy the contents of the File
    By ravichandavar in forum Excel Help
    Replies: 16
    Last Post: 08-15-2012, 09:17 PM
  4. Macro to create files as per the contents in a column
    By Praveen Bj in forum Excel Help
    Replies: 1
    Last Post: 07-05-2012, 09:07 PM
  5. Replies: 4
    Last Post: 05-14-2012, 11:58 AM

Posting Permissions

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