Function result differs from same code for subroutine

Tech-Archive recommends: Fix windows errors by optimizing your registry



this is mad... am trying to write a function to return the first cell
in a filtered list...
but while developing it I came across this...

these two pieces of code are exactly the same, except one is in a
function...

the subroutine returns all my filtered cells, the function returns
everything!!!!

any clues whats happening???

Function fRow() As String
a = 0
For Each c In
Sheets(1).AutoFilter.Range.SpecialCells(xlCellTypeVisible)
a = a + 1
'If a = 2 Then fRow = c.Value
Debug.Print c.Value
Next
End Function
'------------------------------------
Sub fRow2()
a = 0
For Each c In
Sheets(1).AutoFilter.Range.SpecialCells(xlCellTypeVisible)
a = a + 1
'If a = 2 Then fRow = c.Value
Debug.Print c.Value
Next
End Sub

.


Quantcast