I'm looking to select the 2nd visible value from autofiltered range.
I have a table MyTable and looking to get the value from column G (also named as MyRange). The code snippet below works fine with autofiltered range, but all I can do is locate the first visible value in a column G - .Offset(n, 1) will not make any difference, I'm always getting the first value.
Second simple code works fine to locate the 2nd value in a range, however ignores the filtering results.
Am I missing the proper parameters for Offset function in the 1st code? I could probably use helper range, copy the filtered range there and then run the second code which works with unfiltered range, however I feel there has to be a nicer way to do it. Alternative to a 2nd value could also be the last visible value in range.
I have a table MyTable and looking to get the value from column G (also named as MyRange). The code snippet below works fine with autofiltered range, but all I can do is locate the first visible value in a column G - .Offset(n, 1) will not make any difference, I'm always getting the first value.
Code:
Sub Select()
With ActiveSheet.ListObjects("MyTable").Range
Range("A1").Value = Range("G" & .Offset(1, 1).SpecialCells(xlCellTypeVisible).Row).Value
End With
End Sub
Second simple code works fine to locate the 2nd value in a range, however ignores the filtering results.
Code:
Sub Select2()
Range("A1").Value = Range("MyRange").Cells(2, 1).Value
End Sub
Am I missing the proper parameters for Offset function in the 1st code? I could probably use helper range, copy the filtered range there and then run the second code which works with unfiltered range, however I feel there has to be a nicer way to do it. Alternative to a 2nd value could also be the last visible value in range.
Last edited: