View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Lionel H Lionel H is offline
external usenet poster
 
Posts: 31
Default Autofiltered cells not "Hidden"

Dave,
Thanks for the reply.
your first offering works, is simplest and therefore the best.
I thought I had tried this but looking back through my tests,
I find I had used:
If not selection.entirerow.hidden then
DOH!
Thanks again.
Lionel

"Dave Peterson" wrote:

if mycell.entirerow.hidden = false then
'do your stuff
...
end if

Or you could look at just the visible cells in the selection

dim vRng as range
set vrng = nothing
on error resume next
set vrng = intersect(selection,selection.cells.specialcells(x lcelltypevisible)
on error goto 0

if vrng is nothing then
'no cells are visible!
else
for each mycell in vrng.cells
'do something
next mycell
end if

Lionel H wrote:

Having selected a number of cells, I use the following to process them:

Sub Demo1()
Dim myCell
For Each myCell In Selection
€˜Do some processing:
Debug.Print myCell.Value
Next myCell
End Sub

This works fine until I select cells across cells hidden by the autofilter
The above macro includes the cells hidden by the autofilter which I do not
want.
I amend my code as follows:

Sub Demo2()
Dim myCell
For Each myCell In Selection
If Not myCell.Hidden Then €˜this line fails €€œ 1004 Unable to get the
Hidden property of the range class
€˜Do some processing:
Debug.Print myCell.Value
End If
Next myCell
End Sub

I have used debug watch on myCell and Selection and cannot find an
alternative way of skipping the autofiltered cells.
Can anyone help please?


--

Dave Peterson