Public Sub CopyFirstLast()
Dim i As Long, _
LR As Long
LR = Range("Q" & Rows.Count).End(xlUp).row
Application.ScreenUpdating = False
For i = 17 To LR
If Rows(i).Hidden = False And Range("Q" & i).Value <> "" Then
Range("Q" & i).Copy Destination:=Range("A1")
Exit For
End If
Next i
Range("Q" & LR).Copy Destination:=Range("A2")
Application.ScreenUpdating = True
End Sub