Khi copy dữ liệu trong Excel copy dòng ẩn khi paste thường hiển thị cả dòng ẩn nên bạn có thể sử dụng code sau đây để Excel chỉ copy các dòng được hiển thị.
Sub Button1_Click()
Dim rngSource As Range, rngDestination As Range, cell As Range, cc As Long, i As Long
On Error Resume Next
Application.DisplayAlerts = False
Set rngSource = Application.InputBox("Chon vung copy. ", "Vung copy", Type:=8)
If rngSource Is Nothing Then
Application.DisplayAlerts = True: Exit Sub 'User canceled
End If
Set rngDestination = Application.InputBox("Chon vung paste", "Vung Paste", Type:=8)
If rngDestination Is Nothing Then Application.DisplayAlerts = True: Exit Sub 'User canceled
On Error GoTo 0
Application.DisplayAlerts = True
cc = rngSource.Columns.Count
For Each cell In rngSource.Columns(1).SpecialCells(xlCellTypeVisible)
Do
i = i + 1
Loop Until Not rngDestination(1).Offset(i).EntireRow.Hidden
rngDestination(1).Offset(i).Resize(1, cc).Value = cell.Resize(1, cc).Value
Next
End Sub




