Hi. I am totally new to macros and so am a total VBA dummy.

However, I have the problem that I need to delete excess columns out of many files. All files should contain the same columns according to a predfined list of headers.

I found a thread with this 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("Word Pay Cost Volume Rank Type", Cells(1, ColCtr).Text) = 0 Then
Cells(1, ColCtr).EntireColumn.Delete
ColCtr = ColCtr - 1
End If
Next ColCtr
End Sub

It works well, but I have more than 100 column headers and was wondering if there is a way to define a list and put this in the if condition instead of pasting in 100 text items.

Anyone have any ideas?

Thanks

I have the same problem: I need to delete all excess columns in many files, I tried the code and it works well. The only problem I have is that I have about 100 columns that I want to keep.
Is there any way of creating a list and putting it in the code to avoid pasting in so much text?