Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning a value forom a Module to a Userform
I am trying to make a userform to return some data from the spreadsheet after
the analysis is done in a public Sub. How do I call the variable from the public module to the userform? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning a value forom a Module to a Userform
You mean something like this ?
'<Userform code Private Sub CommandButton1_Click() MsgBox MyFunction(20, 10) End Sub '</Userform code '<Module code Public Function MyFunction(Arg1 As Long, Arg2 As Long) As Long MyFunction = Arg1 * Arg2 End Function '</Module code NickHK "CSUS_CE_Student" wrote in message ... I am trying to make a userform to return some data from the spreadsheet after the analysis is done in a public Sub. How do I call the variable from the public module to the userform? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning a value forom a Module to a Userform
Close, but to a Sub, not a function.
How would i do that from a UserForm and a Sub "NickHK" wrote: You mean something like this ? '<Userform code Private Sub CommandButton1_Click() MsgBox MyFunction(20, 10) End Sub '</Userform code '<Module code Public Function MyFunction(Arg1 As Long, Arg2 As Long) As Long MyFunction = Arg1 * Arg2 End Function '</Module code NickHK "CSUS_CE_Student" wrote in message ... I am trying to make a userform to return some data from the spreadsheet after the analysis is done in a public Sub. How do I call the variable from the public module to the userform? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning a value forom a Module to a Userform
You can't return a value from a sub*; that's what a function is for.
Why do you not want a function ? * Well, you can pass an argument ByRef, the default in VB/VBA, and change its value in the sub. NickHK "CSUS_CE_Student" wrote in message ... Close, but to a Sub, not a function. How would i do that from a UserForm and a Sub "NickHK" wrote: You mean something like this ? '<Userform code Private Sub CommandButton1_Click() MsgBox MyFunction(20, 10) End Sub '</Userform code '<Module code Public Function MyFunction(Arg1 As Long, Arg2 As Long) As Long MyFunction = Arg1 * Arg2 End Function '</Module code NickHK "CSUS_CE_Student" wrote in message ... I am trying to make a userform to return some data from the spreadsheet after the analysis is done in a public Sub. How do I call the variable from the public module to the userform? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Extracting a month name forom a date | Excel Worksheet Functions | |||
How to call a sub from UserForm Module | Excel Programming | |||
Userform/Module | Excel Programming | |||
Textbox in Userform not recognised by Module | Excel Programming | |||
Delete userform/module using VB | Excel Programming |