[]
        
(Showing Draft Content)

Access Areas in a Range

While working with a large worksheet having non-contiguous selections, you can access specific areas in a multiple-area range by using the indexer notation of the IAreas interface. The Count property of the IAreas interface represents the area count (number of areas) of the multiple-area range.

The Areas property of the IRange interface represents all the selected ranges in the multiple area range.

Refer to the following example code to access areas in a range.

//area1 is A5:B7.
var area1 = worksheet.Range["A5:B7,C3,H5:N6"].Areas[0];

//set interior color for area1
area1.Interior.Color = Color.Pink;

//area2 is C3.
var area2 = worksheet.Range["A5:B7,C3,H5:N6"].Areas[1];

//set interior color for area2
area2.Interior.Color = Color.LightGreen;

//area3 is H5:N6.
var area3 = worksheet.Range["A5:B7,C3,H5:N6"].Areas[2];

//set interior color for area3
area3.Interior.Color = Color.LightBlue;