Please help with data extraction from text!

MarkusDude

New Member
Joined
Dec 30, 2008
Messages
9
[FONT=&quot]Hello, once again I am here to ask for your help. Thanks you folks in advance. I have spent almost all day trying to get this done but no success. Please help!<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]I have a text file that came from a web form. I have to convert this text (see shortened text below) to excel so that I will have name, last name, email, address... etc in columns. Something like:<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]FirstName LastName email Company<o:p></o:p>[/FONT]
[FONT=&quot]Mark Smith smith@atheynest.net Maguna Police Department<o:p></o:p>[/FONT]
[FONT=&quot]John Horm john.horms@adessthr.com horms auto auctions<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]<o:p>==============</o:p>[/FONT]
[FONT=&quot]<o:p>SHORTENED SAMPLE TEXT
</o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]From: Mark Smith<smith@atheynest.net><o:p></o:p></smith@atheynest.net>[/FONT]
[FONT=&quot]Date: Wed, 06 Oct 2010 09:14:34 -0500<o:p></o:p>[/FONT]
[FONT=&quot]To: webmaster@myplace.com<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]Tool Registration Form<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]Submitted From: My company inc <o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]First Name: Mark <o:p></o:p>[/FONT]
[FONT=&quot]Last Name: Smith<o:p></o:p>[/FONT]
[FONT=&quot]E-mail: smith@atheynest.net<o:p></o:p>[/FONT]
[FONT=&quot]Company: Maguna Police Department<o:p></o:p>[/FONT]
[FONT=&quot]Phone: 9706414582<o:p></o:p>[/FONT]
[FONT=&quot]Fax: 9707335293<o:p></o:p>[/FONT]
[FONT=&quot]Address: 209 West Wiltun Ave<o:p></o:p>[/FONT]
[FONT=&quot]Address2: <o:p></o:p>[/FONT]
[FONT=&quot]City: Appleton <o:p></o:p>[/FONT]
[FONT=&quot]State: New York<o:p></o:p>[/FONT]
[FONT=&quot]Province: <o:p></o:p>[/FONT]
[FONT=&quot]Zipcode: 59915-1613<o:p></o:p>[/FONT]
[FONT=&quot]Country: USA<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]Set: <o:p></o:p>[/FONT]
[FONT=&quot]Purchased From: <o:p></o:p>[/FONT]
[FONT=&quot]Purchase Date: <o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]Comments:<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]IP Address: 24.408.44.207<o:p></o:p>[/FONT]
[FONT=&quot]Remote Host: CPE-29-208-48-207.net.res.rr.com<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]From: John Horm<john.horm@athsa.com><o:p></o:p></john.horm@athsa.com>[/FONT]
[FONT=&quot]Date: Wed, 06 Oct 2010 09:15:17 -0500<o:p></o:p>[/FONT]
[FONT=&quot]To: webmaster@myplace.com<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]Tool Registration Form<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]Submitted From: High Tech Tools <o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]First Name: John<o:p></o:p>[/FONT]
[FONT=&quot]Last Name: Horm<o:p></o:p>[/FONT]
[FONT=&quot]E-mail: john.Horm@adrthsa.com<o:p></o:p>[/FONT]
[FONT=&quot]Company: horms auto auctions<o:p></o:p>[/FONT]
[FONT=&quot]Phone: 365788762<o:p></o:p>[/FONT]
[FONT=&quot]Fax: <o:p></o:p>[/FONT]
[FONT=&quot]Address: 16800 nw 48 ave<o:p></o:p>[/FONT]
[FONT=&quot]Address2: <o:p></o:p>[/FONT]
[FONT=&quot]City: Queen Land<o:p></o:p>[/FONT]
[FONT=&quot]State: fl<o:p></o:p>[/FONT]
[FONT=&quot]Province: <o:p></o:p>[/FONT]
[FONT=&quot]Zipcode: 38054<o:p></o:p>[/FONT]
[FONT=&quot]Country: <o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]Set: <o:p></o:p>[/FONT]
[FONT=&quot]Purchased From: <o:p></o:p>[/FONT]
[FONT=&quot]Purchase Date: <o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]Comments:<o:p></o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]<o:p> </o:p>[/FONT]
[FONT=&quot]IP Address: 247.242.83.12<o:p></o:p>[/FONT]
[FONT=&quot]Remote Host: surf01.ad[/FONT][FONT=&quot]thy[/FONT][FONT=&quot].com[/FONT]
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try this:
Code:
Sub Import_Web_Form_Data()

    Dim filename As String, line As String
    Dim fn As Integer
    Dim row As Long
    
    filename = "C:\path\to\your\webformdata.txt"
    row = 1
    
    fn = FreeFile
    Open filename For Input As fn
    While Not EOF(fn)
        Input #fn, line
        If InStr(line, "First Name: ") = 1 Then
            row = row + 1
            Cells(row, "A").Value = Split(line, ": ")(1)
        End If
        If InStr(line, "Last Name: ") = 1 Then Cells(row, "B").Value = Split(line, ": ")(1)
        If InStr(line, "E-mail: ") = 1 Then Cells(row, "C").Value = Split(line, ": ")(1)
        If InStr(line, "Company: ") = 1 Then Cells(row, "D").Value = Split(line, ": ")(1)
    Wend
    Close fn
    
End Sub
 
Upvote 0
The email addresses in you post look real. If they are, you should ask the admin to edit the post to remove them so that spam agents don't grab them!
(Just a helpful hint)
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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