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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

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