https://www.excelforum.com/excel-pro...ml#post4382748
https://www.excelfox.com/forum/showt...ll=1#post24173
Hallo !
Thanks for the replies
Quote Originally Posted by rorya View Post
You need to be referring to fm.OptionButton2 not ufResults.OptionButton.....
So I tried
v = fm.OptionButton2.Value
instead in the Worksheet_change Code
It works !!! – gives True or False appropriately !
Thanks!!
Here goes the Nut rambling again, sorry about that..
Clearly I have not a clue about user Forms and sadly running out of time to learn.
All I see is in the VB Project Window is ufResults, so I thought that “is” the UserForm ??
That tied up with what Richard suggested. He suggested
UserForm1.
Now... if I insert a new Userform, it gets the name
UserForm1.
The one you did for me has this name
ufResults.
So clearly There seems some logic to what I tried to do?
And the lines with that in do not error, ( just always give False )
_..........................
Quote Originally Posted by rorya View Post
If you need access to these from other routines, you should move the declaration of fm appropriately.
Sorry i do not ( did not ) get it as usual, I guess it means to do with to get the last Three lines to work in this code in a normal module, may be ?
Code:Sub CheckOptionCheckCheckedCheck() Dim v As Variant Let v = ufResults.StatusBarNormal.Value 'Always gives False Let v = ufResults.OptionButton2.Value 'Always gives False Let v = ufResults.Refresh.Value 'Always gives False 'Let v = fm.StatusBarNormal.Value 'At attempt to run code error with complie "error variable not defined" 'Let v = fm.OptionButton2.Value 'Let v = fm.Refresh.Value End Sub
I spent some considerable time being very precise about referring to Ranges correctly but clearly I have no idea what / where the parallel is with User Forms...
So, can I ask
_ What is fm ?
And
_ What is ufResults?
_ How come I can access ( I mean it does not error in those lines above ) ufResults from elsewhere,
but not fm from other than where it is...
Or is this parallel to Code Modules, like this: If I Declared it in a normal module, then would I be able to access it elsewhere. – ( Sorry with this one I hesitate to experiment. – I do not want to create UserForms all over the place hap hazadly !!)*****
In my VB Project Window ufResults does not seem to be tied down to a Sheet. And , again, I cannot find this “thing” fm anywhere! What is fm!!!
Or how about.
ufResults is a sort of class thing, and fm is one instance of it. *****
Alan
_............................
*****Edit: OKI I did anyway experiment
Just to balance out a bit...
I did this .... I “kloned”
_- got two with things showing
May be I do get it... a bit,Code:If fm Is Nothing Then Set fm = New ufResults If Not fm.Visible Then fm.Show False 'make sure UserForm is always there, Static fm2 As ufResults If fm2 Is Nothing Then Set fm2 = New ufResults If Not fm2.Visible Then fm2.Show False
I did this, and the second code does not work...
_............................Code:Sub MakeAInstanceOfufResults() Static fm2 As ufResults If fm2 Is Nothing Then Set fm2 = New ufResults If Not fm2.Visible Then fm2.Show False Dim v As Variant Let v = fm2.StatusBarNormal.Value 'At attempt to run code error with complie "error variable not defined" Let v = fm2.OptionButton2.Value Let v = fm2.Refresh.Value End Sub Sub CheckOptionCheckCheckedCheckOffm2() Dim v As Variant 'Let v = fm2.StatusBarNormal.Value 'At attempt to run code error with complie "error variable not defined" 'Let v = fm2.OptionButton2.Value 'Let v = fm2.Refresh.Value End Sub
But now I do this in a normal Module:
(_....And this in my Worksheet:Change code..Code:Public fm2 As ufResults Public fm As ufResults
_.......)Code:'Static fm As ufResults
and all is well
All the following work , that is to say give the results I expect.
There, you see, preparing concisely in a Thread Reply can help you sometimes get there yourself...Code:Option Explicit 'Public RefreshCColumn As Boolean 'For Check box to recalculate all values ' I do not need this now as i think the Nut has User Forms sussed... Public fm2 As ufResults Public fm As ufResults Sub MakeAInstanceOfufResults() If fm2 Is Nothing Then Set fm2 = New ufResults If Not fm2.Visible Then fm2.Show False Dim v As Variant Let v = fm2.StatusBarNormal.Value Let v = fm2.OptionButton2.Value Let v = fm2.Refresh.Value End Sub Sub CheckOptionCheckCheckedCheckOffm2() Dim v As Variant Let v = fm2.StatusBarNormal.Value Let v = fm2.OptionButton2.Value Let v = fm2.Refresh.Value End Sub Sub CheckOptionCheckCheckedCheckOffm() Dim v As Variant Let v = fm.StatusBarNormal.Value Let v = fm.OptionButton2.Value Let v = fm.Refresh.Value End Sub
I Thanks us, you and me
Alan





Reply With Quote
Bookmarks