+ Reply to Thread
Results 1 to 14 of 14

More efficient way to find and delete columns

Hybrid View

  1. #1
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: More efficient way to find and delete columns

    Loop back word

    Sub DelColumnNotInList1()
    Dim LastCol As Long, ColCtr As Long
    Application.ScreenUpdating = 0
    LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
        For ColCtr = LastCol To 1 Step -1
        If InStr("Text1 Text2 text3 Text4 Text5 Text6 Text7 Text8 Text9 Text10", Cells(1, ColCtr).Text) = 0 Then
                Columns(ColCtr).Delete
        End If
        
        Next ColCtr
       Application.ScreenUpdating = True
    End Sub

  2. #2
    Registered User
    Join Date
    04-04-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: More efficient way to find and delete columns

    Thanks so much for that.
    I've gone from 3:54 to 1:46 which is excellent.
    Since it is now counting backwards, would reversing the order of my search strings have any impact??
    Anyone else have any ideas to improve on 1:46???
    Thanks again.
    I love this forum.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1