fi.or.jp.de brought next idea :
First userform1 gives option to input username and password
once it logs into the system automatically close the userform1
and userform2 loads - shows the progress of the macro or the work
done.
Once the userform1 unloads userform2 is not visible , I need to click
on excel......
Okay, it sounds like you're using the login userform to show a progress
bar. If this is the case then your code needs to be something like
this:
Sub DoStuff()
fUserLogin.Show
If Not fProgress Is Nothing Then
'do whatever needs fProgress displayed
Unload fProgress
End If
End Sub
On fUserLogin, include an OK button that when clicked it validates the
login. If (and only if) the login validates then include code to open
fProgress vbModeless and unload the login form something like this:
Sub cmdOK_Click()
If bValidateUserLogin Then fProgress.Show vbModeless
Unload Me
End Sub
...where bValidateUserLogin is the function that returns the result of
login validation as a boolean value (true or false). So.., if login is
successful then fProgress displays because your function will return a
value of TRUE.
If bValidateUserLogin returns false then fProgress isn't opened, and
your DoStuff routine will need to know how to handle that. In this case
it checks to see if fProgress is open before attempting to do anything
and then close it. The code example doesn't let the code execute unless
fProgress is open, meaning user login was validated.
So to sum up the changes needed, Userform1 should control its own
unloading and whether Userform2 is displayed. Your procedure should
display Userform1 and execute code then unload Userform2 only if it's
loaded.