LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel VSTO: Selecting range according to properties

I found the following solution:

// Gets the selected range
Excel.Worksheet activeWorksheet = Globals.ThisAddIn.Application.ActiveSheet;
Excel.Range activeRange = Globals.ThisAddIn.Application.Selection.Cells;
Excel.Range expandedRange = activeRange.EntireRow; // selects entire rows

List<string laddr = new List<string();

foreach (Excel.Range r in expandedRange.Rows) // this returns only the rows not hidden
if (!r.Hidden)
laddr.Add(r.Address[true,true]);

Excel.Range selectedRange = activeWorksheet.Range[string.Join(";", laddr)];

selectedRange.Select();

So I get the string representing the range in each row and then use Range[] to obtain the desired range object.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting two different columns in excel using VSTO Kiran Excel Programming 0 March 8th 10 01:24 PM
Range.Value2 in C# (Excel 2007, VSTO 2008)? Fabz[_2_] Excel Programming 2 December 8th 09 02:51 PM
Storing add-in properties with workbook - how to? (VSTO 2007) Thomas[_24_] Excel Programming 2 September 23rd 09 08:09 AM
Formulas assignment from array to range in VSTO Excel doesn't work vsto excel array to range Excel Worksheet Functions 0 December 11th 07 04:48 PM
VSTO: insert one row into a 1-row range jj_online Excel Programming 0 June 23rd 06 03:17 AM


All times are GMT +1. The time now is 04:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"