using ATPVBAEN.XLA!Random to write to a text file?

F

festdaddy

I'm using ATPVBAEN.XLA!Random to create discretely distributed random
data sets, but I'd like to write them to a text file, or perhpas just
to an array that I can then dump to a text file, but so far I can't get
any output other than a range, worksheet, or workbook (the built-in
options). I guess I could write to a new workbook and save as a text
file, but I was hoping to learn to do it more directly.

Thanks,
Rob
 
G

Guest

Here is an example.

Replace the random number line with your desired code:

Sub EEE()
Dim ff As Long, i As Long
Dim v As Single
ff = FreeFile()
Open "C:\MyRandom.Txt" For Output As #ff

For i = 1 To 1000
v = Int(Rnd() * 10000 + 5000)
Print #ff, v
Next
Close #ff
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top