|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 计算()
- With Sheet1
- r = .[b65536].End(3).Row
- arr = .Range("c4:e" & r) '长宽高
- For i = 1 To UBound(arr)
- gym = .Cells(i + 3, "J")
- la = InStr(gym, "A"): If la > 0 Then a = CInt(Mid(gym, la - 1, 1)) Else a = 0 '“A”前面的数字
- lb = InStr(gym, "B"): If lb > 0 Then b = CInt(Mid(gym, lb - 1, 1)) Else b = 0 '“B”前面的数字
- lp = InStr(gym, "P"): If lp > 0 Then p = CInt(Mid(gym, lp - 1, 1)) Else p = 0 '“P”前面的数字
- gy = .Cells(i + 3, "G")
- If gy = "A" Then .Cells(i + 3, "L") = (a * arr(i, 1) + b * arr(i, 2)) / 1000
- If gy = "B" Then .Cells(i + 3, "M") = (a * (arr(i, 1) * arr(i, 3)) + b * (arr(i, 2) * arr(i, 3)) + p * (arr(i, 1) * arr(i, 2))) / 1000000
- Next
- End With
- End Sub
复制代码 你自己试验一下,我是按自己理解做的公式。如果不对把公式改一下。 |
|