|
- Sub lqxs()
- Dim myPath$, myName$
- Dim Arr1, i&, wb As Workbook, n&, j&, aa, Brr(1 To 25, 1 To 1)
- Dim d, k, t, d1, k1, Arr2, Arr3
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set wb = ThisWorkbook
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- myPath = ThisWorkbook.Path & ""
- myName = "企业人工成本情况(示例).xlsx"
- With GetObject(myPath & myName)
- Arr1 = .Sheets(1).Range("A1").CurrentRegion
- For i = 2 To UBound(Arr1)
- d1(Arr1(i, 1)) = i
- Next
- .Close False
- End With
- myName = "企业在岗职工工资调查(示例).xlsx"
- With GetObject(myPath & myName)
- Arr2 = .Sheets(1).Range("A1").CurrentRegion
- Arr3 = .Sheets(1).Range("k1").Resize(UBound(Arr2), 16)
- For i = 2 To UBound(Arr2)
- d(Arr2(i, 1) & "") = d(Arr2(i, 1) & "") & i & ","
- Next
- .Close False
- End With
- k = d.keys: t = d.items
- For i = 0 To UBound(k)
- If d1.exists(k(i)) Then
- n = d1(k(i))
- For j = 2 To 11
- Brr(j - 1, 1) = Arr1(n, j)
- Next
- For j = 12 To 15
- Brr(j, 1) = Arr1(n, j)
- Next
- For j = 16 To UBound(Arr1, 2)
- Brr(j + 1, 1) = Arr1(n, j)
- Next
- Sheet1.[b2].Resize(25, 1) = Brr: Erase Brr
- End If
- t(i) = Left(t(i), Len(t(i)) - 1)
- If InStr(t(i), ",") Then
- aa = Split(t(i), ",")
- For j = 0 To UBound(aa)
- Sheet2.Cells(j + 4, 1).Resize(1, UBound(Arr3, 2)) = Application.Index(Arr3, aa(j), 0)
- Sheet2.Cells(j + 4, 17) = Arr2(aa(j), UBound(Arr2, 2))
- Next
- Else
- Sheet2.Cells(4, 1).Resize(1, UBound(Arr3, 2)) = Application.Index(Arr3, t(i), 0)
- Sheet2.Cells(4, 17) = Arr2(t(i), UBound(Arr2, 2))
- End If
- With ActiveWorkbook
- .SaveAs myPath & k(i) & ".xls"
- End With
- Next
- MsgBox "OK"
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|