Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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
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
Autofilter method of range class failed Scott Excel Programming 2 September 8th 09 12:49 PM
Issue when accessing the property/method of a Calender control Anand Excel Programming 0 January 12th 07 05:36 AM
AutoFilter method of Range class failed maboli Excel Programming 2 November 17th 06 02:19 PM
Accessing rows after AutoFilter MartynGriffin Excel Programming 4 January 16th 06 10:05 PM
AutoFilter method of Range Class Failed Randy Reese Excel Programming 3 April 3rd 04 04:34 AM


All times are GMT +1. The time now is 05:03 PM.

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

About Us

"It's about Microsoft Excel"