Option Explicit[b]
Sub CopyToSheet()[/b]
Dim LastColumn As Integer, iCot As Integer
Dim LastRow As Long, lHang As Long
Dim wRng As Range, Rng As Range, UniRng As Range
1 [COLOR="Blue"]'. Tim Dong & Cot Cuoi[/COLOR]
If WorksheetFunction.CountA(Cells) > 0 Then
LastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
LastColumn = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
End If
2 [COLOR="blue"]'.Noi Cac Dong Chua Du Lieu[/COLOR]
For lHang = 1 To LastRow
Set Rng = Range(Cells(lHang, 1), Cells(lHang, LastColumn))
For Each wRng In Rng
If wRng.Value <> "" Then
If UniRng Is Nothing Then
Set UniRng = Rng
Else
Set UniRng = Union(UniRng, Rng)
End If
Exit For
End If
Next wRng, lHang
3 [COLOR="blue"]'. Chep Vung Du Lieu Sang Sheet Moi[/COLOR]
UniRng.Copy Destination:=Worksheets("S1").Range("A1")
[B]End Sub[/B]