XL5: Unexpected Results Copying/Pasting Filtered List

Last reviewed: September 12, 1996
Article ID: Q115429
The information in this article applies to:
  • Microsoft Excel for Windows, version 5.0

SYMPTOMS

In Microsoft Excel version 5.0, when you run a recorded Visual Basic macro to copy and paste a filtered list, you may receive unexpected results. When you manually copy a filtered list and then paste it, only the filtered items are pasted. However, when you use a recorded macro to do this same task, the macro may paste all of the items in the list, not just the filtered items.

NOTE: This unexpected behavior does not occur when you run a macro recorded in the Microsoft Excel 4.0 Macro language.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.

WORKAROUND

In Visual Basic, Applications Edition, the Selection.CurrentRegion.Select method will select all items in a list, not just the filtered items. To select only the visible cells before you perform the copy, specify the following just before the Selection.Copy command in the module sheet:

   Selection.SpecialCells(xlVisible).Select

To record a macro with only visible cells selected, do the following before you choose the Copy command:

  1. Select the filtered list.

  2. From the Edit menu, choose Go To.

  3. Choose the Special button.

  4. Choose Visible Cells Only, and then choose OK.

The Selection.SpecialCells(xlVisible).Select command will be added to the macro, which will cause only the visible cells to be selected.


KBCategory: kbusage kbmacro
KBSubcategory:

Additional reference words: 5.00 Filter



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: September 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.