I am trying to get value of some publicly declared userform variable into other module written in other sheets.
first myform.show function initialize the form and set i = 0. But when I closed the form using x button and used the queryclosed function to update the value of i and control return to Myform.val = 10 line then userform_initialize() function is again called and the condition becomes false becoze it again set the i to 0. I don't know why this is happening. Any help please.
my sheet module code is as follows:
Sub myModule()
Myform.Show
If Myform.val=10 then
msg "Hi"
End if
End sub
and Myform code is as follows:
Public i as integer
Private Sub UserForm_Initialize()
i = 0
End sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode <> 1 Then
i = 10
End If
End Sub
I want the above if condtion to be true if form is closed using x button and false if form is closed using commandbutton.