|
Sub LoadData()
Application.ScreenUpdating = False
Dim rn As Range
Dim sh As Worksheet, sht As Worksheet
Set sh = ThisWorkbook.Worksheets("214")
Set sht = ThisWorkbook.Worksheets("216")
sh.[a1].CurrentRegion.Offset(1).Clear
sht.[a1].CurrentRegion.Offset(1).Clear
f = Dir(ThisWorkbook.Path & "\*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
With wb.Worksheets(1)
Set rn = .[a1].CurrentRegion.Offset(1)
End With
If InStr(wb.Name, "214") > 0 Then
ws = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
rn.Copy sh.Cells(ws, 1)
ElseIf InStr(wb.Name, "SA") > 0 Then
ws = sht.Cells(Rows.Count, 1).End(xlUp).Row + 1
rn.Copy sht.Cells(ws, 1)
End If
wb.Close False
End If
f = Dir
Loop
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|