Lock in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Is it possible to include in a VBA macro a command to would block an user to
interacte with the Excel window, while a VBA macro is running ?
Jeff
 
Hi Jeff

You might show a (modal) userform while the thing runs. Preferrably one that
shows "working" or the progress of your code.

HTH. Best wishes Harald
 
Hello,

I already have an userform. Can I write something in my macro ?
Thanks,
 
Hi again

Well, you cant lock everything down. But see if this does it.
In the Userform1 module (change all over to fit your userform name):

Private Sub UserForm_Activate()
Me.Caption = "Working..."
Me.Repaint
DoEvents
Call Macro1(True)
End Sub

And in a standard module:

Sub Runit()
UserForm1.Show
End Sub

Sub Macro1(X As Boolean)
Dim L As Long
Application.Visible = False
DoEvents
'sample time consuming loop:
'replace with real action:
For L = 1 To 10000
ActiveSheet.Cells(1, 1).Value = L
Next
'done, keep this:
Application.Visible = True
Unload UserForm1
End Sub

HTH. Best wishes Harald
 

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

Back
Top