User Form

  • Thread starter Sri via OfficeKB.com
  • Start date
S

Sri via OfficeKB.com

Hello all

I am writing a VB macro in XL which has 5 major phases. I would like to
display a user form to the user when the macro begins to execute. This user
form will have the list of my 5 phases and a check box before each phase. At
the beginning, all the 5 boxes will be unchecked, indicating that none of the
phases completed. Once a particular phase finishes, I would like to tick the
checkbox corresponding to this phase. This will clearly give an indication to
the user what the macro is doing.

I use the following code but not working. Control stops after displaying the
ApplicationStatus (user form) and not moving to next statements until I close
the user form. Any help please…

My requirement is to continue execution of the macro, keeping this user form
displayed.

Regards
Sri

Sub MainMacro()

ApplicationStatus.CheckBox1.Value = 1
ApplicationStatus.CheckBox2.Value = 0
ApplicationStatus.CheckBox3.Value = 0
ApplicationStatus.CheckBox4.Value = 0
ApplicationStatus.CheckBox5.Value = 0
ApplicationStatus.Show

‘Beginning of phase 1
Command 1 …
Command 2 …
Command 3 …
‘End of phase 1

Unload ApplicationStatus
ApplicationStatus.CheckBox1.Value = 1
ApplicationStatus.CheckBox2.Value = 1
ApplicationStatus.CheckBox3.Value = 0
ApplicationStatus.CheckBox4.Value = 0
ApplicationStatus.CheckBox5.Value = 0
ApplicationStatus.Show

‘Beginning of phase 2
Command 1 …
Command 2 …
Command 3 …
‘End of phase 2

etc…. etc….

End Sub
 
O

Office_Novice

Option Explicit

Private Sub UserForm_Activate()
Call CheckStatus(1)
'Do Phase 1
Call CheckStatus(2)
'Do phase 2
'And So on

End Sub

Function CheckStatus(i As Long)
If i = 1 Then UserForm1.CheckBox1.Value = True
If i = 2 Then UserForm1.CheckBox2.Value = True
If i = 3 Then UserForm1.CheckBox3.Value = True
If i = 4 Then UserForm1.CheckBox4.Value = True
If i = 5 Then UserForm1.CheckBox5.Value = True
End Function
 
S

Sri via OfficeKB.com

Thank you friend. Thank you for your reply.

Office_Novice said:
Option Explicit

Private Sub UserForm_Activate()
Call CheckStatus(1)
'Do Phase 1
Call CheckStatus(2)
'Do phase 2
'And So on

End Sub

Function CheckStatus(i As Long)
If i = 1 Then UserForm1.CheckBox1.Value = True
If i = 2 Then UserForm1.CheckBox2.Value = True
If i = 3 Then UserForm1.CheckBox3.Value = True
If i = 4 Then UserForm1.CheckBox4.Value = True
If i = 5 Then UserForm1.CheckBox5.Value = True
End Function
Hello all
[quoted text clipped - 48 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top