|
Sub 汇总数据()
Application.ScreenUpdating = False
Dim wb As Excel.Workbook
With Sheets("汇总")
.UsedRange.Offset(3).ClearContents
.UsedRange.Offset(3).Borders.LineStyle = 0
f = Dir(ThisWorkbook.Path & "\*.xls*") '生成查找EXCEL的目录
Do While f <> "" '在目录中循环
If f <> ThisWorkbook.Name Then '如果不是打开的工作簿
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f)
x = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
y = wb.Worksheets("人力成本").Cells(Rows.Count, 1).End(xlUp).Row
ar = wb.Worksheets("人力成本").Range("a4:aa" & y - 1)
.Range("A" & x).Resize(UBound(ar), UBound(ar, 2)) = ar
.Range("A" & x).Resize(UBound(ar), UBound(ar, 2)).Borders.LineStyle = 1
wb.Close False
End If
f = Dir
Loop
For i = 4 To .Cells(.Rows.Count, 1).End(xlUp).Row
.Cells(i, 1) = i - 3
Next i
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|