|
- Sub vvv()
- Dim arr, brr
- Set d = CreateObject("scripting.dictionary")
- arr = Sheet2.[a1].CurrentRegion
- For i = 2 To UBound(arr)
- d(arr(i, 1)) = arr(i, 2)
- Next
-
- With Sheet1
- brr = .Range("c2:d" & .[a1].Cells(Rows.Count, 1).End(xlUp).Row)
- For i = 1 To UBound(brr)
- If InStr(brr(i, 1), "+") > 0 Then
- s = Split(brr(i, 1), "+")
- For x = 0 To UBound(s)
- ss = Split(s(x), "*")
- brr(i, 2) = brr(i, 2) + d(ss(0)) * Val(ss(1))
- Next
- Else
- ss = Split(brr(i, 1), "*")
- brr(i, 2) = d(ss(0)) * Val(ss(1))
- End If
-
- Next
- .[d2].Resize(UBound(brr), 1) = Application.Index(brr, , 2)
- End With
-
- End Sub
复制代码
|
|