Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting a month name forom a date Finance Guru Excel Worksheet Functions 5 May 28th 09 05:42 PM
How to call a sub from UserForm Module Myles[_58_] Excel Programming 1 March 31st 06 04:40 AM
Userform/Module saziz[_16_] Excel Programming 3 October 17th 05 12:14 AM
Textbox in Userform not recognised by Module SuperJas Excel Programming 5 February 26th 04 07:11 PM
Delete userform/module using VB Rohit Thomas Excel Programming 5 July 16th 03 11:01 PM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"