Macro Message Box

L

lahuwm

Hi, I am trying to build a macro for a histogram. When the macro is complete,
I am asked "Histogram - Some data will be hidden by embedded chart(s)." I
can click OK or cancel. How can I build my OK response into the macro so
that I do not need to manually respond? Thank you for reviewing my question.
 
M

Mike H

Hi,

AFAIK message boxes are modal so you can't do that but you can do it with a
userform. Create a userform and put a text box on it and include this line in
you code at the appropriate point. Note the declaration of Mytext as Public

Public MyText As String
Sub YourSub()
'Your Code
MyText = "An informative message"
UserForm1.Show
End Sub

Attach this code to the userform and it will display your message and close
after 10 seconds.

Private Sub UserForm_Activate()
TextBox1.Text = MyText
Application.Wait (Now + TimeValue("0:00:10"))
Unload UserForm1
End Sub



--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
E

EricG

If that message is system generated, then you canadd the following to your
code to eliminate the message:

Application.DisplayAlerts = False ' Turns off system generated messages

....your code here...

Application.DisplayAlerts = True ' Turns system generated messages back on

HTH,

Eric
 

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