Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
rea rea is offline
external usenet poster
 
Posts: 6
Default Copy data from .txt to .xls

Problem:I have a .txt which contains 100 rows (each row is only one
word or number).
I managed to copy all 100 values into .xls (all 100 data in one
column).but i need to split those 100 values into 5 colums (each column
would contain 20 values).
like this: .txt
1
2
3
4
5
6
..
..
..
100

..xls would look like this:
1 21 41
2 22 42
3 23 .
4 . .
.. . .
.. . .
20 40 60 and so on, till 100.
please could somebody help me

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Copy data from .txt to .xls

Well, you can easily do that with your mouse, but since you are posting
in a "programming" news group, I assume you need a VBA solution. Here
is one, but it is untested. This will copy original data from column A
to columns B ... F

----------------------------------------
public sub Copy_alll

dim s As Excel.Worksheet

set s = activesheet

call Copy_Section (s, 1, 20, "B")
call Copy_Section (s, 21, 40, "C")
call Copy_Section (s, 41, 60, "D")
call Copy_Section (s, 61, 80, "E")
call Copy_Section (s, 81, 100, "F")
end sub



private sub Copy_Section (s as Excel.Worksheet, fRow as Long, lRow as
long, Col as String)

dim x as long
dim r as long

x = 0
for r = fRow to lRow
x = x + 1
s.Cells (x, Col).value = s.Cells (r, "A").value
next r
end sub


rea wrote:
Problem:I have a .txt which contains 100 rows (each row is only one
word or number).
I managed to copy all 100 values into .xls (all 100 data in one
column).but i need to split those 100 values into 5 colums (each column
would contain 20 values).
like this: .txt
1
2
3
4
5
6
.
.
.
100

.xls would look like this:
1 21 41
2 22 42
3 23 .
4 . .
. . .
. . .
20 40 60 and so on, till 100.
please could somebody help me


  #3   Report Post  
Posted to microsoft.public.excel.programming
rea rea is offline
external usenet poster
 
Posts: 6
Default Copy data from .txt to .xls


thnx, i will try it and let you know does it works!!!

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
filted data, copy and paste a col. puts data in wrong row how fix chris_fig New Users to Excel 1 October 16th 06 04:26 PM
Retrieve multiple data rows data from a very long list and copy t mathew Excel Discussion (Misc queries) 1 September 13th 06 08:24 PM
How do I copy data from main frame computer and keep data in cell Doug Excel Worksheet Functions 1 May 30th 06 05:15 PM
Copy old Data from web query while keeping previous days data DRobidoux Excel Worksheet Functions 0 March 22nd 06 01:56 PM
Copy data into cells until changes trigger new copy mdeanda Excel Programming 2 April 25th 05 01:32 PM


All times are GMT +1. The time now is 08:30 PM.

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

About Us

"It's about Microsoft Excel"