PDA

View Full Version : Update Row with Visible cells in Column



arihan1511
07-08-2015, 11:46 AM
I have filtered list in column A
I want to add the visible cell after filter to First Row of Sheet 1

Ihave found a code to do this but its very long


Public Sub NextValue()
With Sheets("Detail").Range("A2:A50")
Do
ActiveCell.Offset(1).Select

Loop While Rows(ActiveCell.Row).Hidden = True



End With
End Sub

Public Sub UpdateRow()
Sheets("Detail").Range("A1").Select


NextValue
Sheets("Sheet1").Range("A1") = ActiveCell

NextValue
Sheets("Sheet1").Range("B1") = ActiveCell

NextValue
Sheets("Sheet1").Range("C1") = ActiveCell

NextValue
Sheets("Sheet1").Range("D1") = ActiveCell

End Sub


If I want to add all filtered values then I have to add 49 lines of code

"NextValue
Sheets("Sheet1").Range("D1") = ActiveCell"

since range A2:A50

Can anyone simplify the code for me?