Marco循环值并做数学

时间:2018-03-06 06:12:47

标签: vba excel-vba math excel

下面的代码可以分割"逗号"分成价值,但我面临另一个问题。当值为* 1,* 2,* 3等时......我怎么能乘以它?

如您所见,如果该行有"需要跟进",则表示无法从image2值查找。因为值为* 1 / * 2 / etc ......

所以我的问题是,如果image1 2b * 1 = 18且2b * 2 = 36,我该怎么做呢。

IMAGE1

图像2

   For b = 8 To .Cells(8, "D").End(xlDown).Row
        ttl = 0
        ttlerror = ""
        vals = Split(.Cells(b, "D").Value2, Chr(44))
        For a = LBound(vals) To UBound(vals)
            pc = Application.Match(vals(a), sh.Columns(1), 0)
            If Not IsError(pc) Then
                ttl = ttl + sh.Cells(pc, "B").Value2
            ElseIf IsError(pc) Then
                ttlerror = "Need follow-up"
                ttlerrrorcount = ttlerrrorcount + 1
            End If
        Next a
        .Cells(b, "F") = ttl
        .Cells(b, "G") = ttlerror
    Next b

0 个答案:

没有答案
相关问题