The information in this article applies to:
SYMPTOMSWhen you attempt to use the SpecialCells Method in a Microsoft Visual Basic for Applications macro or procedure in Microsoft Excel, you may receive the following error message:
CAUSEThis problem occurs if the following conditions are true:
-and- WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.asp Method 1: Use the SendKeys StatementSome of the SpecialCells constants have keyboard equivalents that can be selected by pressing a specific key combination. For example, to select the last cell in the used range using the SpecialCells method, the xlCellTypeLastCell constant is used. This operation can be simulated on the worksheet by pressing the CTRL+END key combination. Using the SendKeys statement, a macro can simulate pressing this key combination. The following is a macro that provides an example of pressing the CTRL+END key combination and will operate when the worksheet contents are protected:
The following example simulates the xlCellTypeNotes constant of the
SpecialCells method by pressing the CTRL+SHIFT+O key combination:
The other constants (xlCellTypeConstants, xlCellTypeFormulas,
xlCellTypeBlanks, and xlCellTypeVisible) cannot be simulated by using
key combinations.
Method 2: Unprotect the WorksheetIf the SpecialCells method is used on a worksheet with the contents protected, the macro will produce the error listed in the "Symptoms" section of this article. To avoid this error, unprotect the sheet before using the SpecialCells method. Reapply the protection once the cells have been selected. This example unprotects the sheet, selects all blank cells in the used range, and then protects the sheet:
NOTE: If the worksheet is protected by a password, you must supply the
password as an argument for the Unprotect method.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article REFERENCESFor more information about keyboard commands, click the Index tab in Microsoft Excel Help, type the following text keyboard shortcutsand then double-click the selected text to go to the "Use shortcut keys in Microsoft Excel" topic. Additional query words: XL97 goto
Keywords : kberrmsg kbdta kbdtacode KbVBA |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |