What is Range.Cells?

J

Jialiang Ge [MSFT]

Hello Dave,
why does Range have a Cells property?

A range is composed of a cell or cells. Excel.Range[row, column] is
equivalent to Excel.Range.Cells[row, column], and both returns an object
type that we can cast to Excel.Range. row and column are relative position
in the first 'Area' of the range, that is to say Excel.Range[row, column]
returns the range in the relative row and column of Excel.Range.Areas[1].
For instance,
Excel.Range range1 = (Excel.Range)worksheet.Cells[2, 2];
Excel.Range range2 = (Excel.Range)worksheet.Cells[3, 3];
Excel.Range union = application.Union(range1, range2, missing, missing,
missing, missing, missing, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing, missing, missing, missing,
missing, missing); // union the two ranges
Excel.Range result = (Excel.Range)union[1, 1];

The union result has two Areas (union.Areas.Count), and the result range
refers to the cell at absolute position [2, 2], which is the cell in the
relative position [1,1] of the first Area.
are Range and Cells objects an array? And if so, what does Range[0] not
give me a Cell type object?

The type Excel.Cell does not exist. Cells is a property of a range object,
and each cell is still of type Excel.Range. Therefore, Range[1,1] should
return a Excel.Range object. Please note that the index in Excel is 1
based, therefore, we should write Range[1,1] rather than Range[0,0].

If you have any other question, please feel free to let me know.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello Dave,

If there is anything else I can do for you in this issue, please feel free
to let me know.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top