I never said that you can run a procedure in the userform, you can, but that
is not what I said. I just showed you how to get the userform variable.
To do that, you need to declare the procedure as public and use this code
Sub RetrieveCounter()
Load UserForm1
UserForm1.ShowNumberofControls
MsgBox UserForm1.k
Unload Userform1
End Sub
Don't forget to declare k as a modula public variable else it will be local
to the procedure.
--
HTH
RP
(remove nothere from the email address if mailing direct)
"davidm" wrote in
message ...
Hi Bob,
Thanks for your reply. I am however still at sea. Suppose, for an
illustration, I have a code in a Userform module that counts the number
of controls on the Form and wish to retieve the count in a general
module. The standard code in the USerform module will look like:
Private Sub ShowNumberofControls()
Dim c as Control
For Each c In Me.Controls
k = k + 1
Next
..And in the general module
Sub RetrieveCounter()
Call ShowNumberOfControls
Msgbox Userform1.k
End Sub
The above stalls at *Call ShowNumberOfControls *with a *Complie Error:
Sub or Function not defined* message.
Have I misconstrued your guidance?
David.
--
davidm
------------------------------------------------------------------------
davidm's Profile:
http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=488169