Excel VBA Paste Special - replace contents of destination cells

  • Thread starter Sam via OfficeKB.com
  • Start date

S

Sam via OfficeKB.com

Hi All,

I'm using Paste Special in a Macro to copy the format and column widths etc
and overwrite some existing data in the destination cells.

Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

I receive an Information Alert message: "Do you want to replace the contents
of the destination cells? Yes / No"

How can I reply "Yes" to the Alert Message within the Macro to prevent user
intervention?

Thanks
Sam
 
Ad

Advertisements

J

Jim Cone

Sam,
You can't reply to it, but you can use the following to prevent
the message from appearing...

Application.DisplayAlerts = False

Set this back to True before exiting the Sub.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Sam via OfficeKB.com" <[email protected]>
wrote in message Hi All,
I'm using Paste Special in a Macro to copy the format and column widths etc
and overwrite some existing data in the destination cells.

Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

I receive an Information Alert message: "Do you want to replace the contents
of the destination cells? Yes / No"
How can I reply "Yes" to the Alert Message within the Macro to prevent user
intervention?
Thanks
Sam
 
Ad

Advertisements

S

Sam via OfficeKB.com

Hi Jim,

Thank you very much for your assistance: that worked Great!

Cheers
Sam

Jim said:
Sam,
You can't reply to it, but you can use the following to prevent
the message from appearing...
 

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