LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to pass a variable from Form back to calling procedure

I want to call a form from a procedure, selected the value of a
variable in the form, and pass the value back to the procedure. How can
I do this?

Here is what I've tried.

--------calling proc-----------

Public strVariable as String

Sub CallingProcedure()
Dim procVar1 as string
...

strVariable=""

frmUserForm14.Show vbModeless

cellLinkI = strVariable
...

End Sub
------------------------------
----code in frmUserForm14-----
(no declarations)

Public butOkay_Click()
Dim strFormVar as String

strFormVar=""
If strFormVar="X" Then
strVariable=strFormVar
Else
strVariable="Z"
End If

Unload Me

End Sub
------------------------------

When this code is run, the value of strVariable after the call is "".

Another way to do this might be to call the form with the variable
"ByRef" so that it is returned to the variable in the calling
procedure.

Maybe the problem is that the Form is not a Module.

Thank you.

John Wirt

 
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
Pass switch to Main procedure Bob Phillips[_6_] Excel Programming 0 August 3rd 05 11:23 PM
Pass variable from user form to macro r wilcox Excel Programming 1 May 23rd 05 07:27 PM
Is it possible to open the VBA form with a link in a sheet and to pass variable from a cell to the VBA form? Daniel[_14_] Excel Programming 1 August 29th 04 01:20 PM
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM
Calling variable from user form Geraldon Excel Programming 2 February 9th 04 03:18 PM


All times are GMT +1. The time now is 05:14 PM.

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

About Us

"It's about Microsoft Excel"