Michael Zh.

We all know that we can get a range object by using: get_range("A1:B1"), but if I have a range object, how can I get its address string --> "A1:B1"

I wants to create a chart and give its source value as "A1:B1,D1:F1,G1:H1", so I need to get the string of range address.

Thanks



Re: Visual Studio Tools for Office How to get the range string of a worksheet.range object

Asim Patnaik

Hi,

From a given range, you can get the address from the get_Address method:

Code Snippet

string strAddress = range.get_Address(System.Reflection.Missing.Value);

This may return strings in different format depending upon the way the range is selected i.e.

1. If it is a series of consecutive cells, then the string value would be like $A$1EmbarrassedC$1

2. If the selected cells are scattered, then the string value would be like $A$4,$B$6 or $A$1EmbarrassedC$1,$M$1EmbarrassedN$1

3. If only one cell is selected, then the string would be like $A$1

Hope this is of help

Btw, currently I am using Excel 2000.

Regards,

Asim.






Re: Visual Studio Tools for Office How to get the range string of a worksheet.range object

Asim Patnaik

Please replace the smiley with : and $ signs.

Regards,

Asim.