Hi,
I want to sum the cells in Column A in condition that the date in Column B is later than 1/1/2016.
I need it for VBA because I'm running this on 100 sheets.
TIA
Nati
Try
Somewhere put =SumDate(A1:B14;"1/1/2016")
Adjust the range to your need
Code:
Option Explicit
Function SumDate(WkRg As Range, WkDate As Date) As Double
Dim Rg As Range
For Each Rg In WkRg.Columns(1).Cells
If (Rg.Offset(0, 1) < WkDate) Then SumDate = SumDate + Rg
Next Rg
End Function
Just curious how this works as a VB. I use SUMIFS all the time with multiple columns /rows and nest several. If I did VB how does it execute ? I guess it’s all programmed
Function SumDate1(WkRg As Range, WkDate As Date) As Double
Dim Rg As Range
SumDate1 = Application.SumIf(WkRg.Columns(2).Cells, "<1/1/2016", WkRg.Columns(1).Cells)
End Function
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.