Microsoft KB Archive/36888

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


Excel: Copying and Pasting Regions Through a Macro

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("CopyArea",SELECTION())
   =SET.NAME("PasteArea",INPUT("Select the area to paste to",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.


KBCategory: kbother

KBSubcategory:

Additional reference words: 1.00 1.03 1.04 1.06 1.50 2.20 3.00


Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.