|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub ok()
- Dim arr, brr, crr, drr, err, frr(), m, k, s
- Application.ScreenUpdating = False
- Columns("A:C").EntireColumn.AutoFit
- arr = Range([A1], Range("C" & Range("C1048576").End(xlUp).Row))
- For m = 1 To UBound(arr, 1)
- If InStr(Left(arr(m, 3), InStr(3, arr(m, 3), " ")), "-") = 0 Then
- brr = Replace(arr(m, 3), Left(arr(m, 3), InStr(3, arr(m, 3), " ")), "")
- Else
- brr = Trim(arr(m, 3))
- End If
- crr = Split(brr, "/")
- For j = 0 To UBound(crr)
- drr = Split(Trim(crr(j)), "+")
- For k = 0 To UBound(drr)
- i = i + 1
- ReDim Preserve frr(1 To 3, 1 To i)
- If InStr(drr(k), ")") <> 0 Then
- err = Right(Replace(drr(k), ")", ""), Len(Replace(drr(k), ")", "")) - InStr(Replace(drr(k), ")", ""), "("))
- s = Replace(drr(k), Mid(drr(k), InStr(drr(k), "("), Len(drr(k))), "")
- If i = 1 Then frr(1, i) = arr(m, 1) Else frr(1, i) = arr(m, 1) & " X " & err
- If i = 1 Then frr(2, i) = arr(m, 2) Else frr(2, i) = err
- If k = 0 Then frr(3, i) = s Else frr(3, i) = Left(Trim(crr(j)), InStr(Trim(crr(j)), " ")) & s
- Else
- frr(1, i) = arr(m, 1)
- If i = 1 Then frr(2, i) = arr(m, 2) Else frr(2, i) = 1
- If k = 0 Then frr(3, i) = drr(k) Else frr(3, i) = Left(Trim(crr(j)), InStr(Trim(crr(j)), " ")) & drr(k)
- End If
- Next k
- Next j
- Next m
- [E:G].Clear
- [E1].Resize(i, 3) = Application.Transpose(frr)
- Range("E1:G1").Interior.Color = 255
- Columns("E:G").EntireColumn.AutoFit
- With Range("E2:G" & i)
- .Borders(xlEdgeLeft).Color = -16776961
- .Borders(xlEdgeTop).Color = -16776961
- .Borders(xlEdgeBottom).Color = -16776961
- .Borders(xlEdgeRight).Color = -16776961
- .Borders(xlInsideVertical).Color = -16776961
- .Borders(xlInsideHorizontal).Color = -16776961
- End With
- End Sub
复制代码
|
|