Pasting Additional Data to a Database with a Macro

Last reviewed: November 29, 1994
Article ID: Q31634
The information in this article applies to:
  • Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a, 5.0
  • Microsoft Excel for OS/2 versions 2.2, 2.21, and 3.0

SUMMARY

You can use a macro to copy information and add it to the end of an Excel database.

MORE INFORMATION

If there is data in every cell of the first column of the database, use the following procedure:

  1. Select the upper-left cell of the database.

  2. Use the following command to change the selection to the last occupied cell in that column:

          =SELECT.END(4)
    

  3. Use the following command to move the selection one more row downward:

          =SELECT("R[1]C")
    

The current selection will now be in the proper position to paste the new data into the database. If you add to the database, you must redefine the database by selecting the entire database and using the SET.DATABASE command. However, if the database has been defined to include one blank row beneath the initial set of data, it automatically adjusts itself to include the new data.

If there are some blank cells in the first column of the database, use the following function (where SHEET1 is the name of the worksheet and A1 is the upper-left cell of the database):

   =SELECT(OFFSET(SHEET1!A1,ROWS(SHEET1!DATABASE),0))

Please note that the database must be defined for this method to work correctly.

For alternative methods to add information to a database through a macro, query on:

        offset and database and macro and excel


KBCategory: kbother
KBSubcategory:

Additional reference words: 5.00 2.00 2.0 2.01 2.1 2.10 2.2 2.21 2.20 3.00
3.0 4.00 4.0


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 29, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.