Sub read_test2()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
fileToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(fileToOpen, ForReading)
RowCount = 1
Do While f.AtEndOfStream <> True
line1 = f.readline
char_count = 3
column_off = 0
Do While Len(line1) > 2
three_char = Left(line1, 3)
Cells(1, "A").Offset(rowOffset:=0, columnOffset:=column_off).Value = _
three_char
line1 = Mid(line1, 4)
column_off = column_off + 1
Loop
Loop
End Sub
"Sam" wrote:
> Wow thanks for responding so quickly. Well I want to sort the data (I have
> other info that I want to add once I can figure out this part), and I want
> each set of 3 characters to head its own column.
>
> "Joel" wrote:
>
> > I need more information
> > where do you want to add the data into excel?
> > Do you want each lint in the text file in a seperate row of the worksheet
> > all in column A? Then add the spaces to the cell?
> >
> > Or do you wantt each set of 3 characters in a different column?
> >
> > Be careful, there is a limit to the number of characters you can put in each
> > cell. I thinik its 256 characters.
> >
> >
> >
> > "Sam" wrote:
> >
> > > I have a long string of data in a text document that I want to enter into an
> > > Excel document. I also want to insert a space after every three characters.
> > >
> > > For example, AGCTGCCAAGTC
> > >
> > > gets changed to this : AGC TGC CAA GTC, and each of these triplets is in
> > > separate columns
> > >
|