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.
Bookmarks