HighTechTalks DotNet Forums  

Query for a range contained by Range.AutoFilter

Visual Studio.net (Tools Office) microsoft.public.vsnet.vstools.office


Discuss Query for a range contained by Range.AutoFilter in the Visual Studio.net (Tools Office) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Gary Rynearson
 
Posts: n/a

Default Query for a range contained by Range.AutoFilter - 02-17-2010 , 01:46 PM






C# 3.0, Window XP Pro, Visual Studio 2008, Office 2007

I am able to generate a filter using the Range.AutoFilter method on a
ListObject table in Excel. However, elsewhere in the application, I want to
be able to get that filtered range into a Range object.

Any suggestions on how I can go about doing this?


Here is the method I use to filter based on a list of recordId's and a
boolean to either apply or not apply the filter.
void displayRelatedRecordsOnly(bool applyFilter, List<int> recsToShow)

{

object[] criteria = new object[recsToShow.Count];

List<object> oList = new List<object>();

int i = 0;

foreach (int recId in recsToShow)

{

criteria[i++] = recId.ToString();

}

Excel.XlAutoFilterOperator op =

Excel.XlAutoFilterOperator.xlFilterValues;

int idOrdinal = columnPositionByNames["ID"];

dataTable.Range.AutoFilter(idOrdinal,

applyFilter ? criteria : missing,

op, missing, true);

}

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.