I don't claim to be a wiz at VBA, but give this a try. I stepped through it and it seemed to work without doing anything to the selected visible cells.
Code:
Sub cpyfour()
ThisWorkbook.Sheets(4).Rows("1:1").Select
Selection.EntireRow.Hidden = True
ThisWorkbook.Sheets(4).UsedRange.SpecialCells(xlCellTypeVisible).Select
' copy paste code here
Rows("1:1").Select
Selection.EntireRow.Hidden = False
End Sub
You might have to specify the original sheet(4) when setting the hidden property to false. As they say, your mileage may vary.