|
- Sub 拆分()
- Dim arr, brr, crr, drr, err, frr As Worksheet
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Sheet33.Range("A2:f65536").ClearContents
- m = Sheets.Count
- For k = 1 To m
- With Sheets(k)
- If .Name <> "总工资" And .Name <> "流水" Then
- .Activate
- ActiveWindow.DisplayFormulas = True
- a = .Cells(.Rows.Count, 1).End(xlUp).Row
- b = .Cells(2, .Columns.Count).End(xlToLeft).Column - 1
- ReDim arr(1 To a - 2, 1 To b - 2)
- ReDim brr(1 To a - 2)
- ReDim crr(1 To a - 2)
- ReDim drr(1 To b - 2)
- For i = 3 To a
- brr(i - 2) = .Cells(i, 1)
- crr(i - 2) = .Cells(i, 2)
- For j = 3 To b
- If .Cells(i, j) <> "" Then
- arr(i - 2, j - 2) = Replace(.Cells(i, j).Text, "=", "")
- End If
- Next
- Next
- For j = 3 To b
- drr(j - 2) = .Cells(2, j)
- Next
- For i = 1 To a - 2
- For j = 1 To b - 2
- If arr(i, j) <> "" Then
- err = Split(arr(i, j), "+")
- c = UBound(err)
- d = Sheet33.Cells(Sheet33.Rows.Count, 1).End(xlUp).Row + 1
- For n = 0 To c
- Sheet33.Cells(d + n, 5) = err(n)
- Sheet33.Cells(d + n, 1) = crr(i)
- Sheet33.Cells(d + n, 2) = brr(i)
- Sheet33.Cells(d + n, 3) = .Name
- Sheet33.Cells(d + n, 4) = drr(j)
- Next
- err = ""
- End If
- Next
- Next
- ActiveWindow.DisplayFormulas = False
- End If
- End With
- arr = ""
- brr = ""
- crr = ""
- drr = ""
- Next
- Sheet33.Activate
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|