Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nth Cell from visible range

Status
Not open for further replies.

RicksAtWork

Programmer
Nov 1, 2005
120
GB
I want to write a method that will return the value held in the nth VISIBLE cell from the mth row of a range

Function GetNthVisibleCellValue(InputRange As Range, row As Integer, cell As Integer) As String


End Function

i.e. if I pass the function a range which has been filtered and I ask for cell 1 on row 1, it will return the 1st visible cell on the first visible row.

How should I do this?
 
Have a look at the SpecialCells method of the Range object and at the xlCellTypeVisible constant.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Have created this:

'***************************************************************************************
' Returns the Nth Visble Row in a range
'***************************************************************************************

Function GetNthVisibleCellValue(InputRange As Range, row As Integer) As String

Dim count As Integer
count = 1



For Each cl In InputRange.SpecialCells(xlCellTypeVisible)


If count = row Then

GetNthVisibleCellValue = cl

Exit Function

End If

count = count + 1

Next cl



End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top