Share via

Importing into Excel

Anonymous
2017-01-27T15:48:35+00:00

Hello.

I use this old database called AskSam. The company is no longer in business, so I can not get help from them. Basically, I want to import data from AskSam into Excel.

I am able to export AskSam data to a text deliminated file. However, Excel is not placing the information into tables correctly. For example, this is one of my "tab deliinated documents"

Any ideas?

Thanks

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2017-01-27T20:22:32+00:00

Try this macro - I think it requires a reference to MS Scripting Runtime... change the .txt to the actual file extension that you have. It will put the results in column C.

Option Explicit

Sub PullFromFile()

    Dim FSO As Object    'Scripting.FileSystemObject

    Dim ts As Object    'Scripting.TextStream

    Dim Contents As String

    Dim strFN As String

    Dim AllLines As Variant

    Dim i As Long, r As Long

    'Read in the text file

    Set FSO = CreateObject("Scripting.FileSystemObject")

    strFN = Application.GetOpenFilename("Text Delimited Files (*.txt),*.txt")

    Set ts = FSO.OpenTextFile(strFN)

    Contents = ts.ReadAll

    ts.Close

    'Split the lines into an array

    AllLines = Split(Contents, "!@#$%^*")

    'Visit each line

    For i = 0 To UBound(AllLines)

        'Write out the data to column C

        Cells(i + 2, "C").Value = Trim(AllLines(i))

    Next

End Sub

Was this answer helpful?

0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Anonymous
    2017-01-27T19:30:35+00:00

    Im using every method I can thing of. But primarily copy and paste. When I try to use the Excel Import Wizard, it does not work.

    At this point, I do not care if I get them into the correct fields. You see, with AskSam, I have about 1,500 documents. These documents are separate by a string in notepad, specifically, "!@#$%^*". Is there a way I can use this string and Excel to each force each document into a single cell? That way I will have 1,500 cells with data? (ie: One column and 1500 rows?)

    Thanks!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-01-27T17:04:20+00:00

    Are the articles split into separate rows by carriage returns?  Which technique are you attempting to use?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2017-01-27T16:53:41+00:00

    Thank you. I am still running into some problems. I believe the carrier returns in my information is messing things up.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2017-01-27T16:23:01+00:00
    1. Write a macro that opens the file as a text stream, and read the file line by line. Then choose which column to place the data into based on the characters at the start of each line.

    If you are not good with macros:

    1. Open the file - with all the information in column A - and use formulas in other columns to extract the data into those columns.
    2. Open the file - again, with all the information in column A - and sort column A and copy and move blocks of data into your columns manually.

    Was this answer helpful?

    0 comments No comments