0

我用值创建 tab(x,y) :

Dim CostCatTab() As Variant
Dim tabSize As Long

For m = 3 To CCRLastColumn

    CostCategory = wsSum.Cells(CostCagRow, m).Value
    Value = wsSum.Cells(CostCagRow, m).Value

    tabSize = tabSize + 1
    ReDim Preserve CostCatTab(1 To 2, 1 To tabSize)
    CostCatTab(1, tabSize) = CostCategory
    CostCatTab(2, tabSize) = m

Next

进入第二个循环,我想检查当前项目(currentCT)是否进入CostCatTab.CostCategory

如果是,那么我想为 CostCategory 显示适当的 m 值

For h = 10 To x_rows
    currentCT = wsCal.Range("M" & h).Value

Next
4

1 回答 1

0

我做了:

 For h = 10 To x_rows
        currentCT = wsCal.Range("M" & h).Value

    For b = LBound(CostCatTab, 2) To UBound(CostCatTab, 2)
        If CostCatTab(1, b) = currentCT Then
            wsCal.Range("N" & n).Value = wsCal.Range("K" & n).Value * wsSum.Cells(40, CostCatTab(2, b))
            Exit For
        End If
    Next b

 Next h
于 2017-01-13T10:08:03.673 回答