检查二维标签中是否存在值(数组,vb)

Check if value exist into two-dimensional tab (array, vb)

我用以下值创建 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

我做到了:

 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