如果找到 NOMINAL_MAX,我有一個代碼可以匯總我的專案。但是,我想添加一個條件 > 0。當我添加它時,我得到一個“型別不匹配”錯誤。如何解決?
With wbMe.Worksheets("pochodne")
WYCENA_po_CVA_DVA = "WYCENA_po_CVA_DVA"
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
Set rTable = .Range(.Cells(1, 1), .Cells(LastRow, LastCol))
Set rCol = rTable.Rows(1).Find(What:=WYCENA_po_CVA_DVA, LookIn:=xlValues, LookAt:=xlWhole)
If Not rCol Is Nothing Then
.Range("T35").Value = Application.WorksheetFunction.Sum(rTable.Columns(rCol.Column) > 0)
Else
SumCriteria = CVErr(xlErrValue)
End If
End With
uj5u.com熱心網友回復:
你可以這樣使用sumif:
With Worksheets("pochodne")
WYCENA_po_CVA_DVA = "WYCENA_po_CVA_DVA"
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
Set rTable = .Range(.Cells(1, 1), .Cells(LastRow, LastCol))
Set rCol = rTable.Rows(1).Find(What:=WYCENA_po_CVA_DVA, LookIn:=xlValues, LookAt:=xlWhole)
If Not rCol Is Nothing Then
.Range("T35").Value = Application.WorksheetFunction.SumIf(rTable.Columns(rCol.Column), ">0")
Else
SumCriteria = CVErr(xlErrValue)
End If
End With
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/409592.html
標籤:
