Reputation: 3
I have an Excel with data on it. There are some cells which are empty. I am using the following code to sort the data to show only rows with data filled in it.
Issue is when I try to copy paste the data on to another sheet the sorted / hidden rows also get copied and pasted. Any way I can prevent it?
Sub cleanup2()
BeginRow = 8
EndRow = 1220
ChkCol = 52
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 31 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
End Sub
Upvotes: 0
Views: 59
Reputation: 57683
Use .SpecialCells(xlCellTypeVisible)
to get only visible cells.
For Example:
Range("A:A").SpecialCells(xlCellTypeVisible).Copy
copies only the visible cells of column A.
Upvotes: 1