![]() |
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? |
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? |
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? |
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? |
All times are GMT +1. The time now is 07:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com