Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call another function

Status
Not open for further replies.

scottian

Programmer
Jul 3, 2003
955
GB
Still trying to get to this Attachmate stuff. How do i call another function? Ive written the below code, but it
it doesnt work. Any help is appreciate


Sub RandomizeNum()
randomize
randnum% = int(100*rnd)+1
MyPause = ltrim$(str$(randnum%))
End Sub

Sub Main()
Dim appExcel As Object
Dim wbExcel As Object
Dim aSheet As Object
Dim MyPause#

Set AppExcel = CreateObject("Excel.Application")
Set wbExcel = AppExcel.WorkBooks.Open("R:\Tester.xls")
Set aSheet = wbExcel.Sheets("Sheet1")

For x = 2 to aSheet.UsedRange.Rows.Count

Call RandomizeNum

CurrMPRN = aSheet.Cells(x,1).text

Call RandomizeNum

Next

appExcel.Quit
End Sub

"Children are smarter than any of us. Know how I know that? I don't know one child with a full time job and children."...Bill Hicks
 
Never Ive sussed it.

"Children are smarter than any of us. Know how I know that? I don't know one child with a full time job and children."...Bill Hicks
 
Before you get Excel involved, test out the random number function first.

Code:
Function Get_Random_Number() As Integer
   Randomize
   Get_Random_Number = Int(100 * Rnd) + 1
End Function

Sub Main()
   MsgBox Get_Random_Number
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top