Sub MakeSum()
Dim rng1 As Range
Dim objFSO, objFil, txtStr as String, i as Long
Set objFSO = CreateObject("scripting.filesystemobject")
Set objFil = objFSO.opentextfile("C:\test.txt")
txtStr = objFil.readall
Set rng1 = Range([b1], Cells(1, Columns.Count).End(xlToLeft))
Application.ScreenUpdating = False
For i = rng1.Columns.Count To 1 Step -1
If InStr(txtStr, Cells(1, i + 1).Value) = 0 Then Columns(i + 1).Delete
Next i
Application.ScreenUpdating = True
objFil.Close
End Sub
|