Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default writing data to a tab delimited text file?

I'm using VBA to generate random numbers for four fields and write the
data to a text file for use in another program. I'd like the data to be
in tab-delimited format, but the WRITE statement only seems able to
produce comma delimited, and the PRINT statement only seems to produce
spaces. I've searched this group, but all the answers appear to be
related to "save as" type of solutions, which won't work for me as I'm
trying to write 100k+ lines. Is there a way to force WRITE (or PRINT)
to use tabs instead of commas (or spaces)? . is there a "/t"
equivalent type of character I can append to the data or something?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default writing data to a tab delimited text file?

Dim num as long, j as long, i as long
Dim sStr as String
For j = 1 to 100000
sStr = ""
for i = 1 to 4
num = int(rnd()*1000+1)
sStr = sStr & num
if i < 4 then
sStr = sStr & vbTab
end if
Next
' place sStr in your file
Next

--
regards,
Tom Ogilvy


"festdaddy" wrote in message
oups.com...
I'm using VBA to generate random numbers for four fields and write the
data to a text file for use in another program. I'd like the data to be
in tab-delimited format, but the WRITE statement only seems able to
produce comma delimited, and the PRINT statement only seems to produce
spaces. I've searched this group, but all the answers appear to be
related to "save as" type of solutions, which won't work for me as I'm
trying to write 100k+ lines. Is there a way to force WRITE (or PRINT)
to use tabs instead of commas (or spaces)? . is there a "/t"
equivalent type of character I can append to the data or something?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default writing data to a tab delimited text file?

Thanks Tom! the vbTab was what I was missing. I just appended it the
end of each variable and that did the trick. Thanks for posting the
other code as well. Its always instructive to see how others do things.
Thanks again!

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
How can I save a file as a comma-delimited text file in Excel? LAM Excel Discussion (Misc queries) 1 May 3rd 05 10:24 PM
Converting Excel data into semicolon delimited text file danmcgov Excel Discussion (Misc queries) 1 April 14th 05 04:30 PM
Export excel file to semicolon delimited text file capitan Excel Discussion (Misc queries) 5 April 7th 05 03:06 AM
Writing to a text file some data Tom Ogilvy Excel Programming 0 September 9th 04 04:25 PM
Open delimited text file to excel without changing data in that file zohanc Excel Programming 1 October 3rd 03 01:06 AM


All times are GMT +1. The time now is 11:04 AM.

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"