我使用值创建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
答案 0 :(得分: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