Article ID: 108518 - Last Review: October 10, 2006 - Revision: 2.2 Range.EntireRow May Return Incorrect ResultThis article was previously published under Q108518 On This PageSYMPTOMS
In the versions of Microsoft Excel listed at the beginning of this article,
the Range.EntireRow method may return an incorrect result if the Range is a
nonadjacent selection. For example, if the current Range is the nonadjacent
selection $A$1:$A$3, $C$11:$C$13, the Range.EntireRow method will return
$1:$13, not $1:$3,$11:$13 as would be expected. This also occurs when you
use the Range.EntireColumn method to return entire columns when the Range
is nonadjacent.
WORKAROUND
To return the correct rows or columns in a selection when the selection is
nonadjacent, you must separate the selection into Areas, where an Area is
defined as a single piece of a nonadjacent selection. This process is
illustrated in the Visual Basic code example below.
Visual Basic Code ExampleMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. NOTE: To convert this example to work with columns, use "Column" in place of "Row".To use the SelectRows Sub procedure, select any combination of cells on Sheet1. (This example assumes the current selection is $A$1:$A$3,$C$11:$C$13 on Sheet1.) Then, click Macro on the Tools menu, select the name SelectRows from the list of macro names, and click Run. STATUS
Microsoft has confirmed this to be a problem in the versions of Microsoft
Excel listed at the beginning of this article. This problem was corrected
in Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition.
MORE INFORMATION
You can create a nonadjacent selection by selecting a range and then
selecting another range while holding down the CTRL key on your keyboard or
by using Microsoft Excel version 4.0 or Visual Basic commands that select
two or more ranges at the same time.
APPLIES TO
| Article Translations
|


Back to the top
