Finding the first cell in a column that is not hidden

  • Thread starter Thread starter R Tanner
  • Start date Start date
R

R Tanner

Hi,

I need to find the first cell in a column that is not hidden. I am
not sure how to go about this. Any ideas?
 
Hidden cell? Do you mean you have hidden **rows** and you are looking for
the first ROW that is not hidden? This code will do that...

Dim C As Range
For Each C In Rows
If C.Hidden Then
MsgBox "First hidden row: " & C.Address
Exit For
End If
Next

Just replace the MsgBox call with whatever you want to do with that row.

Rick
 
I am trying to figure out a way to use the find method, but I can't
figure out how to specify the criteria as being an unhidden row...
 
To the best of my knowledge, the Find method only finds data, not column or
row 'hiddenness'.

By the way, here is a function that will return the number of the first
hidden row...

Function FirstHiddenRow()
If Not Rows(1).Hidden Then FirstHiddenRow = Split(Split(Cells. _
SpecialCells(xlCellTypeVisible).Rows.Address(False), ",")(0), ":")(1)
FirstHiddenRow = FirstHiddenRow + 1
End Function

Note this uses a totally different method to find the first hidden row than
my earlier posted code (no loops). I am not sure whether it is more
efficient than this function (built around the concept of my earlier posted
code)...

Function FirstHiddenRow()
Dim R As Range
For Each R In Rows
If R.Hidden Then
FirstHiddenRow = R.Row
Exit For
End If
Next
End Function

I'm thinking this last one may be the more efficient of the two (since the
first one makes two calls to the somewhat 'slowish' Split function).

Rick
 
Thank you for the information...I used the
'Selection.SpecialCells(xlCellTypeVisible).Select' method to retrieve
the values I was looking for...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top