ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA Paste Special - replace contents of destination cells (https://www.excelbanter.com/excel-programming/359001-excel-vba-paste-special-replace-contents-destination-cells.html)

Sam via OfficeKB.com

Excel VBA Paste Special - replace contents of destination cells
 
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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200604/1

Jim Cone

Excel VBA Paste Special - replace contents of destination cells
 
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" <u4102@uwe
wrote in message news:5ee08e4c8ec2e@uwe...
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

Sam via OfficeKB.com

Excel VBA Paste Special - replace contents of destination cells
 
Hi Jim,

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

Cheers
Sam

Jim Cone wrote:
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.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200604/1


All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com