|
Sub 按钮1_Click()
w = 5
arr = [a1].CurrentRegion
brr = [a1].Resize(UBound(arr) * 5, 3)
r = 1
With CreateObject("vbscript.regexp")
.Global = True
.Pattern = "(\d+)(×.+?/)"
For j = 2 To UBound(arr)
If .test(arr(j, 3)) Then
str1 = ""
sm = 0
For Each m In .Execute(arr(j, 3))
If sm + Val(m.submatches(0)) >= w Then
If Len(str1) > 0 Then
r = r + 1
brr(r, 1) = arr(j, 1)
brr(r, 2) = arr(j, 2)
brr(r, 3) = str1 & w - sm & m.submatches(1)
sm = Val(m.submatches(0)) - (w - sm)
Else
sm = Val(m.submatches(0))
End If
If sm > 0 Then
str1 = sm & m.submatches(1)
For i = w To sm Step w
r = r + 1
brr(r, 1) = arr(j, 1)
brr(r, 2) = arr(j, 2)
brr(r, 3) = w & m.submatches(1)
Next i
If sm Mod w <> 0 Then
sm = sm - Int(sm / w) * w
str1 = sm & m.submatches(1)
Else
str1 = ""
sm = 0
End If
Else
str1 = ""
sm = 0
End If
Else
sm = sm + Val(m.submatches(0))
str1 = str1 & m.Value
End If
Next m
If Len(str1) > 0 Then
r = r + 1
brr(r, 1) = arr(j, 1)
brr(r, 2) = arr(j, 2)
brr(r, 3) = str1
End If
End If
Next j
End With
[t1].Resize(r, 3) = brr
End Sub
|
评分
-
1
查看全部评分
-
|