+ Reply to Thread
Results 1 to 14 of 14

More efficient way to find and delete columns

Hybrid View

  1. #1
    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

    No Joy
    I'm using this now
    Sub DelColumnNotInList2()
    Dim i&, LC&, myrng1
    Set myrng1 = Range("A1")
         Application.ScreenUpdating = False
         LC = Cells.Find("*", , , , xlByColumns, xlPrevious).Column
    For i = LC To 1 Step -1
        If InStr("Removed", Cells(1, i).Text) = 0 Then
     
            If myrng1 Is Nothing Then
                    Set myrng1 = Cells("1", i)
                Else
                    Set myrng1 = Union(myrng1, Cells("1", i))
                End If
        End If
    Next i
            If Not myrng1 Is Nothing Then
                myrng1.EntireColumn.Delete
            End If
            Application.ScreenUpdating = True
    End Sub
    And I get Runtime Error 1004 Range Class failed on the .EntireColumn.Delete line.
    Sorry for the trouble.
    If I don't include the Set myrng1 piece at the start it throws up the object not defined error.
    Last edited by agentblue; 04-30-2013 at 10:41 AM.

+ 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