Microsoft KB Archive/36888

{| = Excel: Copying and Pasting Regions Through a Macro =
 * width="100%"|

Last reviewed: November 2, 1994

Article ID: Q36888

SUMMARY
When you are copying from one region to another, make sure that the only macro command between the COPY and PASTE command is SELECT.

Many commands can cancel the COPY command and empty the Clipboard. If any of these commands are placed prior to the PASTE [or PASTE.SPECIAL] command, there will be nothing in the Clipboard to paste.

Example
=SET.NAME(&quot;CopyArea&quot;,SELECTION) =SET.NAME(&quot;PasteArea&quot;,INPUT(&quot;Select the area to paste to&quot;,8)) =SELECT(CopyArea) =COPY =SELECT(PasteArea) =PASTE =CANCEL.COPY =RETURN This macro assumes that the area to be copied is the current selection. It then asks you to select the area to paste into. It does no error checking to be sure that these regions are of comparable size. It creates names for these regions, then selects the region to be copied, copies this region, selects the region to paste into, and pastes.
 * }