ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing variables between Sub and Userform (https://www.excelbanter.com/excel-programming/334777-passing-variables-between-sub-userform.html)

jose luis

Passing variables between Sub and Userform
 

Hi All,

I have a sub that assigns a true value to a Boolean Variable. That sub
fires a Userform that needs that boolean value to see if a condition
was met in the sub and then assign certain value to other variable.

I tryed to declare it (Public SwdeLista as Boolean) in Thisworkbook to
make it global (even that i read this is not adviceable, i couldn't
figure another way!), but doesn't work. The SwdeLista boolean variable
keeps "empty".

Could you direct me on how to pass a variable (boolean) from a sub to a
Userform?

Thanks in advance

Jose Luis


--
jose luis
------------------------------------------------------------------------
jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312
View this thread: http://www.excelforum.com/showthread...hreadid=387892


abcd[_3_]

Passing variables between Sub and Userform
 
since the sub seems to be the caller of the form, the proper way may be
to make a special sub : this one will receive the boolean value and
decide the values of the form, and then shows the form.

An other way could be to mask (visible false) a check box but this box
could keep a boolean value from an other code.

Dave Peterson

Passing variables between Sub and Userform
 
If you put that public variable in a general module, does it work ok?

jose luis wrote:

Hi All,

I have a sub that assigns a true value to a Boolean Variable. That sub
fires a Userform that needs that boolean value to see if a condition
was met in the sub and then assign certain value to other variable.

I tryed to declare it (Public SwdeLista as Boolean) in Thisworkbook to
make it global (even that i read this is not adviceable, i couldn't
figure another way!), but doesn't work. The SwdeLista boolean variable
keeps "empty".

Could you direct me on how to pass a variable (boolean) from a sub to a
Userform?

Thanks in advance

Jose Luis

--
jose luis
------------------------------------------------------------------------
jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312
View this thread: http://www.excelforum.com/showthread...hreadid=387892


--

Dave Peterson

jose luis

Passing variables between Sub and Userform
 

Thank you Both,

I'll try that Dave, But that's going to be tomorow cause I'm tired and
sleepy.

Thanks again for your help.

See you around

Jose Luis


Dave Peterson Wrote:
If you put that public variable in a general module, does it work ok?

jose luis wrote:

Hi All,

I have a sub that assigns a true value to a Boolean Variable. That

sub
fires a Userform that needs that boolean value to see if a condition
was met in the sub and then assign certain value to other variable.

I tryed to declare it (Public SwdeLista as Boolean) in Thisworkbook

to
make it global (even that i read this is not adviceable, i couldn't
figure another way!), but doesn't work. The SwdeLista boolean

variable
keeps "empty".

Could you direct me on how to pass a variable (boolean) from a sub to

a
Userform?

Thanks in advance

Jose Luis

--
jose luis

------------------------------------------------------------------------
jose luis's Profile:

http://www.excelforum.com/member.php...o&userid=13312
View this thread:

http://www.excelforum.com/showthread...hreadid=387892

--

Dave Peterson



--
jose luis
------------------------------------------------------------------------
jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312
View this thread: http://www.excelforum.com/showthread...hreadid=387892


Patrick Molloy[_2_]

Passing variables between Sub and Userform
 
in the userform code, have this:

Option Explicit
Public SwdeLista As Boolean

in a code module have this:

Option Explicit
Sub ShowMyForm()
' load the form into memory
Load UserForm1
'adjust any values
UserForm1.SwdeLista = True
'show the form
UserForm1.Show
End Sub



"jose luis" wrote:


Hi All,

I have a sub that assigns a true value to a Boolean Variable. That sub
fires a Userform that needs that boolean value to see if a condition
was met in the sub and then assign certain value to other variable.

I tryed to declare it (Public SwdeLista as Boolean) in Thisworkbook to
make it global (even that i read this is not adviceable, i couldn't
figure another way!), but doesn't work. The SwdeLista boolean variable
keeps "empty".

Could you direct me on how to pass a variable (boolean) from a sub to a
Userform?

Thanks in advance

Jose Luis


--
jose luis
------------------------------------------------------------------------
jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312
View this thread: http://www.excelforum.com/showthread...hreadid=387892



DM Unseen

Passing variables between Sub and Userform
 
In the UserForm1 forms module have this:

Public Sub Myshow (strVal1 as string, bVal2 as boolean)

' do your stuff
Me.show
End sub

In a global module somewhere

UserForm1.MyShow string1,bool2

DM Unseen

PS this can me amended with Property Get/Let/Set procedures and whatnot


jose luis

Passing variables between Sub and Userform
 

Thank you both, for your advice. Now I ll code it.

Read you around

Thanks again

Jose Luis


DM Unseen Wrote:
In the UserForm1 forms module have this:

Public Sub Myshow (strVal1 as string, bVal2 as boolean)

' do your stuff
Me.show
End sub

In a global module somewhere

UserForm1.MyShow string1,bool2

DM Unseen

PS this can me amended with Property Get/Let/Set procedures and whatnot



--
jose luis
------------------------------------------------------------------------
jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312
View this thread: http://www.excelforum.com/showthread...hreadid=387892


jose luis

Passing variables between Sub and Userform
 

Thank you both, for your advice. Now I ll code it.

Read you around

Thanks again

Jose Luis


DM Unseen Wrote:
In the UserForm1 forms module have this:

Public Sub Myshow (strVal1 as string, bVal2 as boolean)

' do your stuff
Me.show
End sub

In a global module somewhere

UserForm1.MyShow string1,bool2

DM Unseen

PS this can me amended with Property Get/Let/Set procedures and whatnot



--
jose luis
------------------------------------------------------------------------
jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312
View this thread: http://www.excelforum.com/showthread...hreadid=387892


jose luis

Passing variables between Sub and Userform
 

Thank you both, for your advice. Now I ll code it.

Read you around

Thanks again

Jose Luis


DM Unseen Wrote:
In the UserForm1 forms module have this:

Public Sub Myshow (strVal1 as string, bVal2 as boolean)

' do your stuff
Me.show
End sub

In a global module somewhere

UserForm1.MyShow string1,bool2

DM Unseen

PS this can me amended with Property Get/Let/Set procedures and whatnot



--
jose luis
------------------------------------------------------------------------
jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312
View this thread: http://www.excelforum.com/showthread...hreadid=387892



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com