I know just enough about this to get it wrong.
I am wanting to delete all the columns in a file except the ones in my defined list. The sub below does the opposite. while workable, I'd rather not define what I want to delete as i have no control over what column names are added in the source file and I will keep having to update the list. I need to keep ~90 columns, so I dont want to define them as a sting within the sub
PACEKEEP is the list of column name i want to keep contour-export is the source file.
Also, i'd like to keep the list PACEKEEP in a file sperate from the working file (call PACEKEEP from a static file). currently i am adding PACEKEEP as a sheet on contour-export
Sub PACEKILL()
Dim f As Range, c As Range
For Each c In Sheets("PACEKEEP").Range("A2", Sheets("PACEKEEP").Range("A" & Rows.Count).End(xlUp))
Set f = Sheets("contour-export").Rows(1).Find(c.Value, , xlValues, xlWhole)
If Not f Is Nothing Then f.EntireColumn.Delete
Next
End Sub
The sub will delete the column headers in the file, I want to delete the columns not in the file