Importing an ASCII time one character per column

  • Thread starter Thread starter Djembe
  • Start date Start date
D

Djembe

I have a file from the results of a 120-question survey. A score from
1-5 has been sent to me (for 500 respondents) in text format. Each
character is crucial - even if its blank. How can I import this into
Excel so that each character goes into a new column (ie, each column
only has one character), without having to use the import wizard and
manually put in a column break 120 times?

Many thanks
 
Another way:

Option Explicit
Sub testme02()

Dim myFileName As Variant
Dim myArray As Variant
Dim iCtr As Long

myFileName = Application.GetOpenFilename("Text Files,*.txt")
If myFileName = False Then
Exit Sub
End If

ReDim myArray(1 To 256, 1 To 2)

For iCtr = 1 To 256
myArray(iCtr, 1) = iCtr
myArray(iCtr, 2) = 1
Next iCtr

Workbooks.OpenText Filename:=myFileName, StartRow:=1, _
DataType:=xlFixedWidth, FieldInfo:=myArray

End Sub

If your filename is *.csv, rename it to *.txt first.
 
That is brilliant help. How about the reverse when I need to export
it? That is, I'll have a spreadsheet of about 1000 rows and 100
columns with one character only in each column. How can I concatenate
each row so that those 100 columns become a long text string and then
save it to a txt file?

Its crucial that I don't get one character out of place.

Many thanks again
 
Back
Top