Suppressing dialog boxes

S

Sian

My Excel macro at several points performs some cut'n'pasting, and the dialog
box appears :
"A formula or sheet you want to move or copy contains the name 'Parnerlist'
which already exists on the destination worksheet. Do you want to use this
version of the name?"
I want the macro to accept a "Yes" programatically and carry on working.
I'm sure there's an easy answer but I haven't found it. Can anyone help?
 
J

JLGWhiz

This produces a message box with your question in it. If the user clicks Yes
then
the code continues as currently written. If the user clicks No then code
that you have yet to compose will execute to change the name of whatever it
is the user is working with and then continue with currently written code.

Msg = "A formula or sheet you want to move or copy contains the name
'Parnerlist'
which already exists on the destination worksheet. Do you want to use this
version of the name?"
doWhat = MsgBox(Msg, vbYesNo + vbQuestion, "MAKE A CHOICE")
If doWhat = vbYes Then
'Do nothing
Else
'Code to change name
End If
 
S

Sian

I see I didn't explain myself very well (well, it is Friday pm!!). I don't
want the dialog box to appear at all - at the moment the user has to sit
there clicking "Yes" 20 times
 
J

JLGWhiz

I am not sure you can use:

Application.DisplayAlerts = False

Then, at a point when the cut and paste is finished:

Application.DisplayAlerts = True

It is difficult to analyze without the code being posted.
 
S

Sian

That worked - thank you!

JLGWhiz said:
I am not sure you can use:

Application.DisplayAlerts = False

Then, at a point when the cut and paste is finished:

Application.DisplayAlerts = True

It is difficult to analyze without the code being posted.
 

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