LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Determine filtered row in excel table with autofilter

You cannot use the property "hidden" on a single cell.
You have to check on the complete table row .

Sub test()
Dim table As Range, row As Range
Set table = Range("c1").CurrentRegion ' c1 is part of the table
For Each row In table.Rows ' table header gets processed also. but you get the idea
If row.Hidden Then
Debug.Print row.Cells(1, 1).Address, "is part of a filtered out row"
Else
Debug.Print row.Cells(1, 1).Address, "is not part of a filtered out row"
End If
Next
End Sub

regards,
Pancras


On Wednesday, February 10, 2010 8:02 PM moonhk wrote:


Hi All

For Excel 2003
When Apply Filter , How to check the row have been filtered out ?

Below coding include filtered out row.

iRows = Application.Selection.Rows.Count
iCols = Application.Selection.Columns.Count


For ir = 1 To iRows
....
Next



On Wednesday, February 10, 2010 8:17 PM Dave Peterson wrote:


You can count the visible cells in a column in the autofilter range:

With activesheet.autofilter.range.columns(1)
if .cells.count = .cells.specialcells(xlcelltypevisible).cells.count then
'all visible
else
'not all visible
end if
end with

But that does not tell you if the data has been filtered--it could be that all
the cells in the filter meet the criteria, so that all rows are visible.

If that is important, you may want to check something like:

With activesheet
if .autofiltermode = true then
'there are autofilter arrows on the worksheet
if .filtermode then
'some filter is applied
'maybe show all the data
.showalldata '????
end if
end if
end with

moonhk wrote:

--

Dave Peterson



On Thursday, February 11, 2010 12:00 AM moonhk wrote:


On 2=E6=9C=8811=E6=97=A5, =E4=B8=8A=E5=8D=889=E6=99=8217=E5=88=86, Dave Pet=
ells.count then
all
the worksheet

Hi All

When Apply filter , some row have been hidden, When I select some row
to process. the hidden also selected. How to check the row is filter
out by filters ?

e.g.
line 1
line 2 <- Filter out
line 3

When select line1 to line3 , the filter out still selected within
blelow for loop

For ir =3D 1 To iRows
....
Next





moonhkt



On Thursday, February 11, 2010 7:08 AM K_Macd wrote:


What you see in interactive name is not the same way that VBA operates. To
emulate a filter to have to expressly put a test condition within your
For/Next block to ignore those rows excluded by the filter.

1. Inconsistent !
2. Excessive coding !

Good luck

--
Ken
"Using Dbase dialects since 82"
"Started with Visicalc in the same year"


"moonhk" wrote:



On Thursday, February 11, 2010 8:24 AM Dave Peterson wrote:


You could check the .hidden property of the cell or you could just loop through
the visible cells.

Here is a sample of the second:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim VisRng As Range
Dim myRng As Range
Dim myCell As Range

Set wks = ActiveSheet

With wks
'just a single column
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))

'remove any existing filter
.AutoFilterMode = False
myRng.AutoFilter Field:=1, Criteria1:="somevalue"

With .AutoFilter.Range.Columns(1)
If .Cells.SpecialCells(xlCellTypeVisible) = 1 Then
MsgBox "only header visible"
Else
'avoid the header
Set VisRng = .Resize(.Cells.Count - 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
For Each myCell In VisRng.Cells
MsgBox myCell.Address 'or whatever you need to do
Next myCell
End If
End With
.AutoFilterMode = False 'remove the filter
End With
End Sub

moonhk wrote:



On Friday, February 12, 2010 1:28 AM moonhk wrote:


On 2=E6=9C=8811=E6=97=A5, =E4=B8=8B=E5=8D=889=E6=99=8224=E5=88=86, Dave Pet=
hrough
, "A").End(xlUp))
mevalue"
peVisible) =3D 1 Then
er visible"
esize(.Cells.Count - 1).Offset(1, 0) _
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .Cells.SpecialCells(xlCellTypeVisibl=
e)
n VisRng.Cells
Box myCell.Address 'or whatever you need to do
=CB=869=C3=A6=E2=84=A2=E2=80=9A17=C3=A5=CB=86=E2=8 0=A0, Dave Peterson <pet=
evisible).cells.count then
that all
le.
e =3D true then
=82 'there are autofilter arrows on the worksheet
=82 if .filtermode then
=82 =C2=A0=C3=82 =C2=A0'some filter is applied
=82 =C2=A0=C3=82 =C2=A0'maybe show all the data
=82 =C2=A0=C3=82 =C2=A0.showalldata =C3=82 '????
=82 end if



On Friday, February 12, 2010 8:53 AM Dave Peterson wrote:


I do not see where you are checking the .hidden property of any single cell's row.



moonhk wrote:



On Saturday, February 13, 2010 2:30 AM moonhk wrote:


's row.
op through
unt, "A").End(xlUp))
"somevalue"
lTypeVisible) =3D 1 Then
eader visible"
der
.Resize(.Cells.Count - 1).Offset(1, 0) _
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.Cells.SpecialCells(xlCellTypeVis=
ible)
l In VisRng.Cells
MsgBox myCell.Address 'or whatever you need to do
er
=CB=869=C3=A6=E2=84=A2=E2=80=9A17=C3=A5=CB=86 , Dave Peterson <peter...@ver=
izonXSPAM.net wrote:
ge:
isible).cells.count then
be that all
isible.
rrows on the worksheet
applied
the data
=82 '????



On Saturday, February 13, 2010 8:23 AM Dave Peterson wrote:


Set Rng_hidden = nothing
on error resume next
Set Rng_hidden = yourlongexpression
on error goto 0

if rng_hidden is nothing then
'it is hidden
else
'it is not
end if



moonhk wrote:



Submitted via EggHeadCafe - Software Developer Portal of Choice
ObjectDumper LINQ To Export Collection Via .NET Reflection
http://www.eggheadcafe.com/tutorials...eflection.aspx

 
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
msg box to apply filter Kirsty Excel Programming 3 May 19th 09 11:31 AM
Apply same filter to all sheets in a workbook manfareed Excel Programming 9 July 31st 08 03:34 PM
Apply format with check box Luis A. Vzquez Excel Programming 1 October 16th 07 03:39 PM
Apply Auto Filter on One Column Bill Foley Excel Programming 5 March 2nd 07 10:16 AM
Macro or VB to apply filter in spreadsheet Stevie[_3_] Excel Programming 2 February 18th 04 03:15 PM


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