I have data that I put in sample.xlsx and the code that should filter the items "CIRS" and FX_FORWARDS from the INSTRUMENT column and sum the values from the NOMINAL_MAX column. However, in the indicated .Range it shows me the value 0
With wbMe.Sheets("pochodne")
If .AutoFilterMode Then .AutoFilterMode = False
Nominal_MAX = "Nominal_MAX"
CIRS = "INSTRUMENT"
FX_FORWARD = "INSTRUMENT"
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:=Nominal_MAX, LookIn:=xlValues, LookAt:=xlWhole)
Set rCol1 = rTable.Rows(1).Find(What:=CIRS, LookIn:=xlValues, LookAt:=xlWhole)
Set rCol2 = rTable.Rows(1).Find(What:=FX_FORWARD, LookIn:=xlValues, LookAt:=xlWhole)
If Not rCol Is Nothing Then
.Range("T39").Value = Application.WorksheetFunction.Round(Application.WorksheetFunction.SumIfs(rTable.Columns(rCol.Column), rTable.Columns(rCol.Column), "<>0", rTable.Columns(rCol1.Column), "CIRS", rTable.Columns(rCol2.Column), "FX_FORWARD"), 0)
Else
SumCriteria = CVErr(xlErrValue)
End If
End With
cross post : https://stackoverflow.com/questions/...-and-sum-issue
Bookmarks