Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default how can I insert a space every three characters?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default how can I insert a space every three characters?

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default how can I insert a space every three characters?

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default how can I insert a space every three characters?

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default how can I insert a space every three characters?

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return cell characters after space Andy Excel Worksheet Functions 3 April 30th 23 12:22 PM
Put A Space Between 2 right characters carl Excel Worksheet Functions 3 April 8th 08 05:08 PM
cHARACTERS BEFORE THE SPACE T De Villiers Excel Worksheet Functions 3 January 19th 06 01:22 AM
Characters before the space T De Villiers[_8_] Excel Programming 3 January 18th 06 10:22 PM
erase all space characters into string Maileen[_2_] Excel Programming 4 January 16th 05 09:10 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"