Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default userforms again...

Sorry I still cannot get this to work.
Private Sub CommandButton2_Click()
MsgBox userSelected
End Sub

userSelected is empty!
The result is not being saved.
Thanks
Jo

Subject: userform inputs
From: "Ed" Sent: 9/19/2003
3:36:32 PM
Jo,

You would need a second routine to test it, right?
Add a second command button and try something like:

Private Sub CommandButton1_Click()
Dim userSelected as String
For Each x In Frame2.Controls
If x.Value = True Then
userSelected = x.Caption
End If
Next
Me.Hide
End Sub

Private Sub CommandButton2_Click()
MsgBox userSelected
End Sub
-----Original Message-----
Hi
Sorry I don't know how to do this.
This is the code I am using to find out which option is
selected.

'Private Sub CommandButton1_Click()
'For Each x In Frame2.Controls
'If x.Value = True Then
'MsgBox x.Caption
'End If
'Next
'Me.Hide
'End Sub

I then cannot dim and set the value (even if I use dim

as
msforms.optionbutton)

Subject: userform inputs
From: "Ed" Sent: 9/19/2003
2:50:11 PM

Jo,

The option box's Value property is:
-1 True. Indicates the item is selected.
0 False. Indicates the item is cleared.

You can set up a variable to hold the value and the use
the variable else where.

-----Original Message-----
Hi
How do I retain information form a userform option box

to
use in later modules.
eg. from a list a fruit I could tell apples had been
selected by a user (using a for next grop within the

frame
controls)
how do I then
(i) call fruit selected in a regular macro
(ii) fill in another userform with the selection.
I think I somehow need to declare user fruit choice,

but
I
am not sure how.
Any help much appreciated
Jo



.

..


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default userforms again...

Jo,

We have to make userSelected available to the whole
wookbook.
Take out the Dim in the button and put this is in This
Workbook:
Public userSelected As String

-----Original Message-----
Sorry I still cannot get this to work.
Private Sub CommandButton2_Click()
MsgBox userSelected
End Sub

userSelected is empty!
The result is not being saved.
Thanks
Jo

Subject: userform inputs
From: "Ed" Sent: 9/19/2003
3:36:32 PM
Jo,

You would need a second routine to test it, right?
Add a second command button and try something like:

Private Sub CommandButton1_Click()
Dim userSelected as String
For Each x In Frame2.Controls
If x.Value = True Then
userSelected = x.Caption
End If
Next
Me.Hide
End Sub

Private Sub CommandButton2_Click()
MsgBox userSelected
End Sub
-----Original Message-----
Hi
Sorry I don't know how to do this.
This is the code I am using to find out which option is
selected.

'Private Sub CommandButton1_Click()
'For Each x In Frame2.Controls
'If x.Value = True Then
'MsgBox x.Caption
'End If
'Next
'Me.Hide
'End Sub

I then cannot dim and set the value (even if I use dim

as
msforms.optionbutton)

Subject: userform inputs
From: "Ed" Sent: 9/19/2003
2:50:11 PM

Jo,

The option box's Value property is:
-1 True. Indicates the item is selected.
0 False. Indicates the item is cleared.

You can set up a variable to hold the value and the use
the variable else where.

-----Original Message-----
Hi
How do I retain information form a userform option box

to
use in later modules.
eg. from a list a fruit I could tell apples had been
selected by a user (using a for next grop within the

frame
controls)
how do I then
(i) call fruit selected in a regular macro
(ii) fill in another userform with the selection.
I think I somehow need to declare user fruit choice,

but
I
am not sure how.
Any help much appreciated
Jo



.

..


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default userforms again...

Putting a global variable in the thisworkbook module makes it global only
within thisworkbook. You can see it using
thisworkbook.UserSelected (it becomes a property of thisworkbook), but more
natural is to declare it in a general module

Public userSelected as String

then you can see it in all other modules in the project.

--
Regards,
Tom Ogilvy

Ed wrote in message
...
Jo,

We have to make userSelected available to the whole
wookbook.
Take out the Dim in the button and put this is in This
Workbook:
Public userSelected As String

-----Original Message-----
Sorry I still cannot get this to work.
Private Sub CommandButton2_Click()
MsgBox userSelected
End Sub

userSelected is empty!
The result is not being saved.
Thanks
Jo

Subject: userform inputs
From: "Ed" Sent: 9/19/2003
3:36:32 PM
Jo,

You would need a second routine to test it, right?
Add a second command button and try something like:

Private Sub CommandButton1_Click()
Dim userSelected as String
For Each x In Frame2.Controls
If x.Value = True Then
userSelected = x.Caption
End If
Next
Me.Hide
End Sub

Private Sub CommandButton2_Click()
MsgBox userSelected
End Sub
-----Original Message-----
Hi
Sorry I don't know how to do this.
This is the code I am using to find out which option is
selected.

'Private Sub CommandButton1_Click()
'For Each x In Frame2.Controls
'If x.Value = True Then
'MsgBox x.Caption
'End If
'Next
'Me.Hide
'End Sub

I then cannot dim and set the value (even if I use dim

as
msforms.optionbutton)

Subject: userform inputs
From: "Ed" Sent: 9/19/2003
2:50:11 PM

Jo,

The option box's Value property is:
-1 True. Indicates the item is selected.
0 False. Indicates the item is cleared.

You can set up a variable to hold the value and the use
the variable else where.

-----Original Message-----
Hi
How do I retain information form a userform option box
to
use in later modules.
eg. from a list a fruit I could tell apples had been
selected by a user (using a for next grop within the
frame
controls)
how do I then
(i) call fruit selected in a regular macro
(ii) fill in another userform with the selection.
I think I somehow need to declare user fruit choice,

but
I
am not sure how.
Any help much appreciated
Jo


.

..


.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default userforms again...

Jo,
If you need to carry a variable over from one Sub to another
you have to set it up as a Global in your Module (General declarations)

Global gFruit As String

NB. Don't Dim gFruit anywhere else.

Private Sub CommandButton1_Click()
Dim x As Integer
For Each x In Frame2.Controls
If x.Value = True Then
MsgBox "The user has selected " & x.Caption
gFruit = x.Caption
End If
Next
Me.Hide
End Sub

gFruit is available throughout your project and will retain it's value until
changed elsewhere.

HTH
Henry

"Jo" wrote in message
...
Sorry I still cannot get this to work.
Private Sub CommandButton2_Click()
MsgBox userSelected
End Sub

userSelected is empty!
The result is not being saved.
Thanks
Jo

Subject: userform inputs
From: "Ed" Sent: 9/19/2003
3:36:32 PM
Jo,

You would need a second routine to test it, right?
Add a second command button and try something like:

Private Sub CommandButton1_Click()
Dim userSelected as String
For Each x In Frame2.Controls
If x.Value = True Then
userSelected = x.Caption
End If
Next
Me.Hide
End Sub

Private Sub CommandButton2_Click()
MsgBox userSelected
End Sub
-----Original Message-----
Hi
Sorry I don't know how to do this.
This is the code I am using to find out which option is
selected.

'Private Sub CommandButton1_Click()
'For Each x In Frame2.Controls
'If x.Value = True Then
'MsgBox x.Caption
'End If
'Next
'Me.Hide
'End Sub

I then cannot dim and set the value (even if I use dim

as
msforms.optionbutton)

Subject: userform inputs
From: "Ed" Sent: 9/19/2003
2:50:11 PM

Jo,

The option box's Value property is:
-1 True. Indicates the item is selected.
0 False. Indicates the item is cleared.

You can set up a variable to hold the value and the use
the variable else where.

-----Original Message-----
Hi
How do I retain information form a userform option box

to
use in later modules.
eg. from a list a fruit I could tell apples had been
selected by a user (using a for next grop within the

frame
controls)
how do I then
(i) call fruit selected in a regular macro
(ii) fill in another userform with the selection.
I think I somehow need to declare user fruit choice,

but
I
am not sure how.
Any help much appreciated
Jo



.

.




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
Help with Userforms Panagiotis Marantos Excel Discussion (Misc queries) 2 July 25th 06 04:26 PM
I need some help with userforms T.c.Goosen1977 Charts and Charting in Excel 0 June 30th 06 09:29 AM
I need some help with userforms T.c.Goosen1977 Excel Discussion (Misc queries) 0 June 30th 06 09:27 AM
UserForms bennyob Excel Discussion (Misc queries) 4 November 7th 05 01:58 PM
userforms Jo[_4_] Excel Programming 2 September 17th 03 10:35 PM


All times are GMT +1. The time now is 03:22 AM.

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"