|
这个代码比较简单,规范的操作是你在汇总表这里新建一个文件夹,文件名叫数据源,用这个代码去汇总
str = ThisWorkbook.Path & "\数据源\"
Set wb0 = ThisWorkbook
hmc = Dir(str)
For i = 1 To 10000
If hmc <> "" Then
Set wb = Workbooks.Open(str & hmc)
For j = 1 To 100
If Left(wb.Sheets(1).Cells(j, 1), 2) = "学历" Then
k = j
End If
Next j
With wb.Sheets(1)
wb0.Sheets(1).Cells(i + 1, 1) = .Cells(1, 2)
wb0.Sheets(1).Cells(i + 1, 2) = .Cells(k, 3)
wb0.Sheets(1).Cells(i + 1, 3) = .Cells(k + 1, 3)
wb0.Sheets(1).Cells(i + 1, 4) = .Cells(k + 2, 3)
wb0.Sheets(1).Cells(i + 1, 5) = .Cells(k + 3, 3)
wb0.Sheets(1).Cells(i + 1, 6) = .Cells(k + 4, 3)
wb0.Sheets(1).Cells(i + 1, 7) = .Cells(k + 5, 3)
wb0.Sheets(1).Cells(i + 1, 8) = .Cells(k + 6, 3)
wb0.Sheets(1).Cells(i + 1, 9) = .Cells(k + 7, 3)
wb0.Sheets(1).Cells(i + 1, 10) = .Cells(k + 8, 3)
wb0.Sheets(1).Cells(i + 1, 11) = .Cells(k + 9, 3)
wb0.Sheets(1).Cells(i + 1, 12) = .Cells(k, 7)
wb0.Sheets(1).Cells(i + 1, 13) = .Cells(k + 1, 7)
wb0.Sheets(1).Cells(i + 1, 14) = .Cells(k + 2, 7)
wb0.Sheets(1).Cells(i + 1, 15) = .Cells(k + 3, 7)
wb0.Sheets(1).Cells(i + 1, 16) = .Cells(k + 4, 7)
wb0.Sheets(1).Cells(i + 1, 17) = .Cells(k + 5, 7)
wb0.Sheets(1).Cells(i + 1, 18) = .Cells(k + 6, 7)
wb0.Sheets(1).Cells(i + 1, 19) = .Cells(k + 7, 7)
wb0.Sheets(1).Cells(i + 1, 20) = .Cells(k + 8, 7)
wb0.Sheets(1).Cells(i + 1, 21) = .Cells(k + 9, 7)
End With
wb.Close
hmc = Dir
End If
Next |
|