Question : Remove all other data and leave just the data in the txt file. Need to delete the colums where data match in row 1.

Hi,

 Remove all other data and leave just the data in the txt file. Need to delete the colums where data match in row 1
Attached is a sample data with 2 sheets.

Please have a look.

Regards
Sharath

Answer : Remove all other data and leave just the data in the txt file. Need to delete the colums where data match in row 1.

I'd tested a Report/xls file from one of your other recent questions with the same sample file name. Pls try this code with B1 as the correct starting point

Cheers
Dave
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
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
Random Solutions  
 
programming4us programming4us