If I need to change the column on worksheet that I want to add the data (from text file) and need to import data from any file name/type (not only from path in the code and text file ), how can I change it?
any help would be appreciated!!Dim O_Fso As Object Dim Txt_File As Object Dim File_Path As String Dim T_Str As String, Str_Ma4 As String Dim T_Bool As Boolean Dim Hld_Data As Variant Dim Ma_H_Boo As Boolean Dim Ctr As Long Dim i As Long Const LL_Cha As String = "CHARGE=" Const LL_End As String = "END IONS" Const LL_Pep As String = "PEPMASS=" T_Bool = False Ma_H_Boo = False Ctr = 0 i = 1 File_Path = "C:\Documents and Settings\User\Desktop\VBAA\tt.txt" 'change to your text file path Set O_Fso = CreateObject("Scripting.FileSystemObject") Set Txt_File = O_Fso.OpenTextFile(File_Path) With Txt_File Do Until .AtEndOfStream = True T_Str = .ReadLine If T_Str = LL_End Then T_Bool = False Ctr = 0 End If If InStr(T_Str, LL_Pep) <> 0 Then Ma_H_Boo = True If Ma_H_Boo Then Hld_Data = Split(T_Str, Chr$(9)) i = i + 1 Cells(i, 1).Value = Replace(CStr(Hld_Data(0)), LL_Pep, "") Cells(i, 2).Value = 0 Cells(i, 3).Value = 0 i = i + 1 Ma_H_Boo = False End If If T_Bool Then Ctr = Ctr + 1 Hld_Data = Split(T_Str, Chr$(9)) Cells(i, 1).Value = Hld_Data(0) Cells(i, 2).Value = Hld_Data(1) Cells(i, 3).Value = Hld_Data(2) If Ctr = 1 Then Cells(i - 1, 4).Value = Str_Ma4 End If i = i + 1 End If If InStr(T_Str, LL_Cha) <> 0 Then T_Bool = True Hld_Data = Split(T_Str, "=") Str_Ma4 = CStr(Hld_Data(1)) Str_Ma4 = Replace(Str_Ma4, "+", "") End If Loop End With Txt_File.Close Set Txt_File = Nothing Set O_Fso = Nothing
Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST
regards pike
If the solution helped please donate here to the RSPCA
Sites worth visiting;
J&R Solutions - royUK
AJP Excel Information - Andy Pope
Spreadsheet Toolbox
VBA for smarties - snb
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks