PC Review


Reply
Thread Tools Rate Thread

how can I insert a space every three characters?

 
 
=?Utf-8?B?U2Ft?=
Guest
Posts: n/a
 
      14th Feb 2007
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      14th Feb 2007
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
>

 
Reply With Quote
 
=?Utf-8?B?U2Ft?=
Guest
Posts: n/a
 
      14th Feb 2007
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
> >

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      14th Feb 2007
bring in your data. Select the single column and do Data=>Text to columns

Select fixed and in the next page of the dialog, click between every 3rd and
4th character.

then continue on.

Turn on the macro recorder before you do this if you want code.

--
Regards,
Tom Ogilvy


"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
>

 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      14th Feb 2007
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
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to insert half of a space instead of a whole space in word. Hucksie Microsoft Word Document Management 4 12th Oct 2010 12:18 PM
Insert Leading Characters If String Is Only 7 Characters Paperback Writer Microsoft Excel Misc 1 21st Apr 2009 08:47 PM
When placing cursor to insert characters it deletes characters scott66moore Microsoft Word Document Management 1 11th Oct 2008 11:05 PM
How do I insert a hard space that keeps characters on same line Cole Durham Microsoft Word Document Management 3 23rd Aug 2008 10:54 PM
my space bar is deleting characters when I try to insert a charac. =?Utf-8?B?bGdlZXI=?= Microsoft Word New Users 1 24th May 2005 01:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:47 PM.