Good morning folks,
With lots of help from browsing this forum and asking a few questions I have finally gotten my large macro to work. I have broken it down into pieces and I have a master macro to call each piece. This makes it easier to tweek the behaviour.
Anyway, one of my subroutines searches row one for certain column headers and deletes the columns that don't contain my search criteria.
The thing is there are about one hundred columns and this part of the macro takes just under 4 minutes to run.
Can anyone suggest a way of making it run more efficiently please.
Here is the code. My search criteria usually appear roughly in order so I am going to start by reversing the order in which they are listed in my code.
Sub DelColumnNotInList()
Dim LastCol As Double
Dim ColCtr As Double
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
For ColCtr = 1 To LastCol
If InStr("Text1 Text2 text3 Text4 Text5 Text6 Text7 Text8 Text9 Text10", Cells(1, ColCtr).Text) = 0 Then
Cells(1, ColCtr).EntireColumn.Delete
ColCtr = ColCtr - 1
End If
Next ColCtr
End Sub
I have actual search items for privacy reasons.
I would appreciate anyones input that could help reduce the runtime of the above routine which as I said is just under 4 minutes.
Thanks in advance.
Bookmarks