I'm struggling to create a sumifs in VBA - i can easily create it in a cell but want to be able able to use it in VBA
I have my code below with my sumifs statement written in theory, could someone help me to put together the sumifs statement properly and the proper Dim and Set qualifiers
Sub TotalUsingSumifs()
' Worksheet is Person's Pay
' My Table is called Table1 - (it is in Person's Pay)
' Table 1 has the following columns (I'll Name the headers)
' Dates - (dates the regular pay was paid on)
' Regular - (numeric pay column)
' My code to get the start and end dates for my criteria
Dim BeginDate As Date
Dim EndDate As Date
PayDate = Date
YearOfPay = Year(PayDate)
BeginDate = DateSerial(YearOfPay, 1, 1)
EndDate = DateSerial(YearOfPay, 12, 31)
' I don't know how to create the sumifs statement to do the following
RegTotal = SumIfs(Regular, Dates, ">=" & BeginDate, Dates, "<=" & EndDate)
' I'm using Regular as my column to sum
' I'm using Dates as my column criteria
' I'm using the criteria ">=" & BeginDate as the 1st day of the year
' I'm using the criteria "<=" & EndDate as the last day of the year
' I want the regular pay for a specific year
End Sub
Thank you in advance ... Hazelwood
I have my code below with my sumifs statement written in theory, could someone help me to put together the sumifs statement properly and the proper Dim and Set qualifiers
Sub TotalUsingSumifs()
' Worksheet is Person's Pay
' My Table is called Table1 - (it is in Person's Pay)
' Table 1 has the following columns (I'll Name the headers)
' Dates - (dates the regular pay was paid on)
' Regular - (numeric pay column)
' My code to get the start and end dates for my criteria
Dim BeginDate As Date
Dim EndDate As Date
PayDate = Date
YearOfPay = Year(PayDate)
BeginDate = DateSerial(YearOfPay, 1, 1)
EndDate = DateSerial(YearOfPay, 12, 31)
' I don't know how to create the sumifs statement to do the following
RegTotal = SumIfs(Regular, Dates, ">=" & BeginDate, Dates, "<=" & EndDate)
' I'm using Regular as my column to sum
' I'm using Dates as my column criteria
' I'm using the criteria ">=" & BeginDate as the 1st day of the year
' I'm using the criteria "<=" & EndDate as the last day of the year
' I want the regular pay for a specific year
End Sub
Thank you in advance ... Hazelwood