Problem running code behind a userform
In a new workbook create userform1
Put a label in the center (label1). Size it about as big as the userform
and fill it with your message - use a large font size.
Now run this code.
Sub Main()
UserForm1.Show vbModeless
DoEvents
For i = 1 To 100
With Worksheets("sheet1")
For Each cell In .Range("A1:A100").Offset(0, i - 1)
cell.Value = Int(Rnd() * 100 + 1)
Next
End With
' just to make it slower.
For k = 1 To 100000
j = j + 1
Next
If i Mod 10 = 0 Then
a = Int(Rnd * 256 + 1)
b = Int(Rnd * 256 + 1)
c = Int(Rnd * 256 + 1)
UserForm1.Label1.ForeColor = RGB(a, b, c)
DoEvents
End If
Next
Unload UserForm1
End Sub
the macro is doing work when it writes random numbers to the sheets. This
just demonstrates a concept. Obviously it is more adaptable to a looping
situation, but if you have a long list of task you would do
task1
update form
task2
update form
task3
update form
task4
etc.
--
Regards,
Tom Ogilvy
"cdb" wrote in message
...
Tom,
Don't suppose you could expand on that could you??
Cheers,
Chris
"Tom Ogilvy" wrote:
Your best bet is to show the userform modeless
userform1.Show vbModeless
then in your update code, have it periodically perform the action on the
userform that makes it blink or flash the way you want.
--
Regards,
Tom Ogilvy
"cdb" wrote in message
...
Having thought about it further, it really needs to be a UserForm
because
the
update part of the macro opens other workbooks and so when this
happens
the
text box will disappear as it's only linked to the sheet on the
Master.
Any
ideas??
Chris
"Markus Scheible" wrote:
Hi unknown,
maybe this is no answer to your question, but if you just
use the userform for displaying the alert while the macro
is working, just use a text box from shapes instead of the
userform, and you don't have all this trouble...
Best
Markus
-----Original Message-----
Message unavailable
|