The information in this article applies to:
SYMPTOMSWhen you run a Visual Basic for Applications macro that uses the Select method to select a specific range of cells, the macro may select a larger range of cells than you specified. CAUSE
This problem may occur when you run a macro that uses the Select method to select a range of cells and performs an action on the selected cells.
The selection is expanded to include B1:C10 because range A1:A10 contains a
merged cell that extends into cells in columns B and C.
NOTE: In this scenario, you cannot select only cells A1:A10 with the mouse. Excel automatically extends the selection to include cells B1:C10 because the range A2:C2 is merged. 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 a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/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.aspTo work around this behavior, use either of the following methods. Method 1Apply the property or method to a specific Range object rather than the Selection object if the selection contains merged cells that span cells outside of that specified range.For example, the following macro selects cells A1:A10 and applies a bold font format to the specific Range object:
Method 2Another alternative is to check whether merged cells exist in the range prior to performing an action. The following macro determines if there are any merged cells in the range A1:A10 prior to formatting the cells. If the selection contains merged cells, it does not apply the bold formatting:
Additional query words: xl2000 selected selecting code
Keywords : kbprg |
Last Reviewed: July 6, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |