Randomised Number

  • Thread starter Thread starter Ravi Sandhu
  • Start date Start date
R

Ravi Sandhu

Hi guys

I am having a problem working this out.

I need to programme a word or excel document, to have a randomly generated
reference number each time it opens.

Also, each time I open the file, I need for it to have 100 different print
outs. (The file is the same, just 100 different reference numbers)

Also, I want to be able to set parametres for the reference number. (i.e.
when I open it in five minutes it prints out a 100 copies of this file, with
ref AB001 - AB100, and next time I open it, it prints out AB101 to AB200)

I hope someone can help with this

Regards
 
For the random number, this code will provide an integer between 1 and 100:

int(100*rnd())

As for the printouts, check the PrintOut method. You'd need to loop through
100 times to get the different sequence number to print; something like the
following (untested) code should do:

Sub RepeatPrint()
Dim x As Integer
For x = 1 To 100
Sheets(1).Range("A1") = "AB" & x
Sheets(1).PrintOut
Next
End Sub
--
HTH -

-Frank
Microsoft Excel MVP
Dolphin Technology Corp.
http://vbapro.com
 
Back
Top