Question

i have a c# code which gets the (excel-2007) worksheets used range as follows

 Excel.Worksheet ws = (Excel.Worksheet)Globals.ThisAddIn.GetActiveWorksheet();
 Excel.Range range = (Excel.Range)ws.UsedRange;

for the current worksheet i know exactly that range is A1:HM232,...but in the future that range may change... how is it possible to get the range info such as A1:HM232 from the used range info?

i can get the rows.count and columns.count... but how to get info such as "HM"?

the reason behind this is that i'm trying to put it later on a formula like

=Sheet1!A1:HM232...

thanks in advance!

Was it helpful?

Solution

I this this method should do it:

range.get_AddressLocal(range.Rows.Count ,range.Columns.Count ,XlReferenceStyle.xlA1 ,null ,ws.UsedRange);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top