#1   Report Post  
Posted to microsoft.public.excel.programming
CMK CMK is offline
external usenet poster
 
Posts: 2
Default SendKeys?

Hi,
I have an autofilter and I want to determine the row number of the start
and end of the filtered data. I thought initially I could use offset
but unfortunately this returns row 2 even although it is hidden (as it
does not match the criteria specified).

I've tried using SendKeys, which looked ideal, to press the equivalent
of the down arrow but it's affecting the module not the worksheet! Can
anyone help me to workout the row number?

Best Regards,

CalumMurdo Kennedy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default SendKeys?

CalumMurdo,

I am sure there are more efficient ways of doing it, but this appears to
return the right answer.

Sub DetectFilteredRows()
'assumes autofilter starts at a1 with a label header, data starts at a2, and
filter is applied
Dim rngFilter As Range
With Sheets(1)
Set rngFilter = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
MsgBox "Last filtered row is at " & rngFilter(rngFilter.Rows.Count,
1).Row
MsgBox "First filtered row is at " &
rngFilter.SpecialCells(xlCellTypeVisible).Cells(1, 1).Row
End With
End Sub

Robin Hammond
www.enhanceddatasystems.com

"CMK" wrote in message
...
Hi,
I have an autofilter and I want to determine the row number of the start
and end of the filtered data. I thought initially I could use offset but
unfortunately this returns row 2 even although it is hidden (as it does
not match the criteria specified).

I've tried using SendKeys, which looked ideal, to press the equivalent of
the down arrow but it's affecting the module not the worksheet! Can
anyone help me to workout the row number?

Best Regards,

CalumMurdo Kennedy



  #3   Report Post  
Posted to microsoft.public.excel.programming
CMK CMK is offline
external usenet poster
 
Posts: 2
Default SendKeys?

Hi Robin,

Robin Hammond wrote:
CalumMurdo,

I am sure there are more efficient ways of doing it, but this appears to
return the right answer.

Sub DetectFilteredRows()
'assumes autofilter starts at a1 with a label header, data starts at a2, and
filter is applied
Dim rngFilter As Range
With Sheets(1)
Set rngFilter = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
MsgBox "Last filtered row is at " & rngFilter(rngFilter.Rows.Count,
1).Row
MsgBox "First filtered row is at " &
rngFilter.SpecialCells(xlCellTypeVisible).Cells(1, 1).Row
End With
End Sub


That works perfectly thanks. Don't know what was up with the SendKeys
but this works fine and dandy, thanks.

CalumMurdo


Robin Hammond
www.enhanceddatasystems.com

"CMK" wrote in message
...

Hi,
I have an autofilter and I want to determine the row number of the start
and end of the filtered data. I thought initially I could use offset but
unfortunately this returns row 2 even although it is hidden (as it does
not match the criteria specified).

I've tried using SendKeys, which looked ideal, to press the equivalent of
the down arrow but it's affecting the module not the worksheet! Can
anyone help me to workout the row number?

Best Regards,

CalumMurdo Kennedy




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
SendKeys Mike Excel Programming 2 July 2nd 04 12:47 AM
Application.sendkeys Adrie Rahanra Excel Programming 1 October 15th 03 04:29 PM
Sendkeys GB[_3_] Excel Programming 0 September 16th 03 10:39 PM
SendKeys Ron de Bruin Excel Programming 3 August 25th 03 10:21 PM
sendkeys mark poole Excel Programming 0 July 11th 03 03:47 PM


All times are GMT +1. The time now is 08:48 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"