ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   userform inputs (https://www.excelbanter.com/excel-programming/277579-re-userform-inputs.html)

Jouni

userform inputs
 
Hi Jo,

(i) call fruit selected in a regular macro


you can always feed the called macro with a parameter. I guess you have an
OK button in your userform? Then just have something like this

Private Sub cmdOk_Click()
Call YourMacro(Me.cboFruits.Value)
End Sub

Sub YourMacro(strFruit as String)
' here's the macro that does the processing....
End Sub

(ii) fill in another userform with the selection.


One way is to keep the original userform loaded but hidden. So when OK
button is pressed, this happens:
Private Sub cmdOk_Click()
frmYourUserform.Hide
Call YourMacro(Me.cboFruits.Value)
End Sub

When it's open but hidden you can refer to the userform controls by
strWhatEverValue = frmYourUserform.cboFruits.Value

I'd recommend then unload the userform when it is not needed anymore by
command
Unload frmYourUserform

One workaround would also be declaring a public variable, which then is used
for storing the values. Unfortunately it's been a while when I last time
used one with many userforms so I cannot recall all the details and you
might end up losing the value when opening and closing several forms... But
you can always play around and see which way works :-)

HTH,
Jouni
Finland


"Jo" wrote in 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





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

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