Sub LayDuLieu()
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
For k = 1 To 12
shName = Right("0" & k, 2)
If SheetExists(shName) = True Then
Sheets(shName).Select
endR = Range("E65000").End(xlUp).Row
Sheets("DuLieu").Range("A" & k) = endR
End If
Next
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub
Public Function SheetExists(shName) As Boolean
Dim x As Object
On Error Resume Next
Set x = ActiveWorkbook.Sheets(shName)
If Err = 0 Then SheetExists = True _
Else SheetExists = False
End Function