VBA Sumifs under two conditions

Status
Not open for further replies.

Palucci

Banned user
Joined
Sep 15, 2021
Messages
138
Office Version
  1. 365
Platform
  1. Windows
I want to create a function that will sum me up for CRD_EKSP_PIER_DC_FIN = "CRD_EKSP_PIER_DC_FIN" CRD_KOR_DC_FIN = "CRD_KOR_DC_FIN" When two conditions are met, where DIFFRENT> 365 and CRD_RWG <1.5 However, my macro shows me a result of 0. Where do I go wrong ?
VBA Code:
Set wbMe = ActiveWorkbook
CRD_EKSP_PIER_DC_FIN = "CRD_EKSP_PIER_DC_FIN"
CRD_KOR_DC_FIN = "CRD_KOR_DC_FIN"
DIFFRENT = "DIFFRENT"
CRD_RWG = "CRD_RWG"
With wbMe.Sheets("NPE")
If .AutoFilterMode Then .AutoFilterMode = False
    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:=DIFFRENT, LookIn:=xlValues, LookAt:=xlWhole)
    Set rCol1 = rTable.Rows(1).Find(What:=CRD_EKSP_PIER_DC_FIN, LookIn:=xlValues, LookAt:=xlWhole)
    Set rCol2 = rTable.Rows(1).Find(What:=CRD_KOR_DC_FIN, LookIn:=xlValues, LookAt:=xlWhole)
    Set rCol3 = rTable.Rows(1).Find(What:=CRD_RWG, LookIn:=xlValues, LookAt:=xlWhole)
    If Not rCol Is Nothing Then
        .Range("T39").Value = Application.WorksheetFunction.SumIfs(rTable.Columns(rCol.Column), rTable.Columns(rCol.Column), ">365", rTable.Columns(rCol3.Column), "<1.5", rTable.Columns(rCol1.Column), "CRD_EKSP_PIER_DC_FIN", rTable.Columns(rCol2.Column), "CRD_KOR_DC_FIN")
    End If
End With

cross post : VBA Sumifs under two conditions
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Cross posted again without adding all links.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,541
Messages
6,120,110
Members
448,945
Latest member
Vmanchoppy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top