Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Accessing the AutoFilter method via VB.net
There seems to be some inconsistency between the Excel VBA and the Excel Dot
Net object models. I implemented auto filtering via the following code in Excel VBA: Selection.AutoFilter However, when I tried to do the same thing in Dot Net, via the following code, the AutoFilter object was not available, causing a compilation error: Friend Shared Sub gsxxxAutoFilter(ByVal vvwksActive As Worksheet) vvwksActive.Cells.Select() vvwksActive.selection 'This does not compile because the selection method does not exist. vvwksActive.Application.Selection.autofilter() 'This does not compile because the autofilter method does not exist, even though I was able to access the Selection object via the Application object. End Sub Does anyone know how to access the AutoFilter method via Dot Net? Thanks in advance. Keith |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Accessing the AutoFilter method via VB.net
Without using Selection, try
Friend Shared Sub gsxxxAutoFilter(ByVal vvwksActive As Worksheet) vvwksActive.Cells.AutoFilter End Sub -- Jacob "Keith Howard" wrote: There seems to be some inconsistency between the Excel VBA and the Excel Dot Net object models. I implemented auto filtering via the following code in Excel VBA: Selection.AutoFilter However, when I tried to do the same thing in Dot Net, via the following code, the AutoFilter object was not available, causing a compilation error: Friend Shared Sub gsxxxAutoFilter(ByVal vvwksActive As Worksheet) vvwksActive.Cells.Select() vvwksActive.selection 'This does not compile because the selection method does not exist. vvwksActive.Application.Selection.autofilter() 'This does not compile because the autofilter method does not exist, even though I was able to access the Selection object via the Application object. End Sub Does anyone know how to access the AutoFilter method via Dot Net? Thanks in advance. Keith |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Accessing the AutoFilter method via VB.net
Jacob,
Thanks for the fast response. In VBA, your approach has the effect of applying AutoFilter to row 1, which is not what I am trying to do. I am trying to apply an AutoFilter starting from Row 7 (which is where my selection is). I have also tried to create a named range and to apply an AutoFilter thereto via the following code: Range("TestRange").AutoFilter This does not work; it does nothing as far as I can tell. No AutoFilter has been applied. Any other ideas? Thanks in advance. (I did not know that the Excel Dot Net object model was different from the VBA one!) Regards, Keith "Jacob Skaria" wrote: Without using Selection, try Friend Shared Sub gsxxxAutoFilter(ByVal vvwksActive As Worksheet) vvwksActive.Cells.AutoFilter End Sub -- Jacob "Keith Howard" wrote: There seems to be some inconsistency between the Excel VBA and the Excel Dot Net object models. I implemented auto filtering via the following code in Excel VBA: Selection.AutoFilter However, when I tried to do the same thing in Dot Net, via the following code, the AutoFilter object was not available, causing a compilation error: Friend Shared Sub gsxxxAutoFilter(ByVal vvwksActive As Worksheet) vvwksActive.Cells.Select() vvwksActive.selection 'This does not compile because the selection method does not exist. vvwksActive.Application.Selection.autofilter() 'This does not compile because the autofilter method does not exist, even though I was able to access the Selection object via the Application object. End Sub Does anyone know how to access the AutoFilter method via Dot Net? Thanks in advance. Keith |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Accessing the AutoFilter method via VB.net
Try
vvwksActive.Range("A7:" & split(vvwksActive.UsedRange.Address,":")(1)).AutoF ilter -- Jacob "Keith Howard" wrote: Jacob, Thanks for the fast response. In VBA, your approach has the effect of applying AutoFilter to row 1, which is not what I am trying to do. I am trying to apply an AutoFilter starting from Row 7 (which is where my selection is). I have also tried to create a named range and to apply an AutoFilter thereto via the following code: Range("TestRange").AutoFilter This does not work; it does nothing as far as I can tell. No AutoFilter has been applied. Any other ideas? Thanks in advance. (I did not know that the Excel Dot Net object model was different from the VBA one!) Regards, Keith "Jacob Skaria" wrote: Without using Selection, try Friend Shared Sub gsxxxAutoFilter(ByVal vvwksActive As Worksheet) vvwksActive.Cells.AutoFilter End Sub -- Jacob "Keith Howard" wrote: There seems to be some inconsistency between the Excel VBA and the Excel Dot Net object models. I implemented auto filtering via the following code in Excel VBA: Selection.AutoFilter However, when I tried to do the same thing in Dot Net, via the following code, the AutoFilter object was not available, causing a compilation error: Friend Shared Sub gsxxxAutoFilter(ByVal vvwksActive As Worksheet) vvwksActive.Cells.Select() vvwksActive.selection 'This does not compile because the selection method does not exist. vvwksActive.Application.Selection.autofilter() 'This does not compile because the autofilter method does not exist, even though I was able to access the Selection object via the Application object. End Sub Does anyone know how to access the AutoFilter method via Dot Net? Thanks in advance. Keith |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Autofilter method of range class failed | Excel Programming | |||
Issue when accessing the property/method of a Calender control | Excel Programming | |||
AutoFilter method of Range class failed | Excel Programming | |||
Accessing rows after AutoFilter | Excel Programming | |||
AutoFilter method of Range Class Failed | Excel Programming |