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
    14
    What about:

    Code:
    Sub M_snb()
        sn = Range("B1:B3")
        For Each it In sn
            Columns(1).Replace it, "", 1
        Next
    End Sub
    Code:
    Sub M_snb()
        sn = Range("B1:B3")
        For Each it In sn
            Columns(1).Replace it, "", 1
        Next
        columns(1).specialcells(4).entirerow.delete
    End Sub
    Last edited by DocAElstein; 07-15-2025 at 02:52 PM.

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by snb View Post
    What about:

    Code:
    Sub M_snb()
        sn = Range("B1:B3")
        For Each it In sn
            Columns(1).Replace it, "", 1
        Next
    End Sub
    On my computer, my code executes in 0.02 seconds on average where as Rajan's executes in 0.03 seconds on average... the code you posted executes in 0.03 seconds on average; HOWEVER the list your code produces is not the same as the list Rajan's and my code produce. The list your code produces is littered with blank cells whereas our list have no blank cells in them. If I add this line of code to your code...

    Columns(1).SpecialCells(xlBlanks).Delete xlShiftUp

    in order to "squeeze out" the blank cells, the code's time balloons to just under 2.5 seconds.

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
  •