XL5: Unexpected Results Copying/Pasting Filtered List

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.

Additional query words: Filter

Keywords :
Version : 5.00
Platform : WINDOWS
Issue type :


Last Reviewed: September 21, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.