Text file to Excel macro/vba help

mattyb102

New Member
Joined
Jul 28, 2011
Messages
1
Hey everybody, so I have been doing a ton of research, but I'm still having trouble writing a macro using vba. This is what I want my macro to do. I would like it to go to a text file in a folder and sort the text file into different tabs in excel. In the text file the far left column of each line starts with either an H,L,N, or C. I would like the macro to sort these lines by those 4 letters, having a different tab in excel for each letter. So there should be 4 tabs, one for each letter. I was hoping I could do this all with a macro button. Any help on what to do or how to go about this would be much appreciated! Thanks!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Get textfile using FSO (File System Object)
Code:
Dim objFSO As New FileSystemObject, objFile As Object
Set objFile = objFSO.OpenTextFile(strPath, ForReading, False, TristateTrue)
'Blah Blah'

Read by line,
Determine H,L,N,or C before inputting the lines into the worksheet
Select worksheet to place the data
Place the data.

Loop through all lines until the end of file.
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,569
Members
452,926
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top