Avoid having to change the year in dates of formulas
Solution 1:
Approach 1
Rather than hardcoding start/end dates in your SUMIFS
functions, generate them using Excel formulae and then reference the cells containing these calculated date values. The DATE
and EOMONTH
functions can be used as shown in the screenshot below.
Your SUMIFS
formula for January can then be changed to:
=SUMIFS(Amount;DPIF;">="&Sheet1!B3;DPIF;"<="&Sheet1!C3)
For the month of January, cell Sheet1!B3
has the start date of the month and Sheet1!C3
has the end date. Change these cell references to wherever you put your calculated date values. For February, the start/end date cells are Sheet1!B4
and Sheet1!C4
, for March Sheet1!B5
and Sheet1!C5
, etc. If your 12 monthly SUMIFS
formulae are arranged as a range of 12 rows by 1 column, you will be able to copy the January formula down to the next 11 months.
The ampersands (& signs) in the formulae each concatenate a comparison operator with the value in the referenced cell, so in the changed formula ">="&Sheet1!B3
is effectively equivalent to ">=01/01/2024"
because Sheet1!B3
delivers the date value of 01/01/2024.
To change the year simply change the value of the year in the appropriate cell - cell Sheet1!B1
in the screenshot. Your 12 monthly SUMIFS
formulae will all automatically refer to the new year's start/end dates, eliminating the need for the formulae to be edited.
This approach also manages the end of month date for February in leap years (as shown in the screenshot in cell C4
).
Approach 2
An alternative approach is to convert the DPIF
date values into month number values by adding an extra range to your existing Amount/DPIF
ranges using the MONTH
function as
=MONTH(date)
where date
represents a date cell in the DPIF
range.
Calling these monthly values MPIF
means you could then use formulae such as
=SUMIFS(Amount;MPIF;1)
=SUMIFS(Amount;MPIF;2)
...=SUMIFS(Amount;MPIF;12)
without having to worry about the year at all.
This monthly approach assumes that you do not have multiple years in your data ranges. If you do, it will sum data for all the January's, all the February's, etc which is possibly not what you want.
In this case, a refinement to the solution is to add year values to the data in a YPIF
range using the YEAR
function to obtain these values. You would then add a second criterion to the SUMIFS
formulae to include these year values, for example
=SUMIFS(Amount;MPIF;1;YPIF;2024)
Of course this means you would still have 12 formulae to modify each year, even though the edits are slightly simpler than those you currently have. To avoid this put the year value in its own cell and reference it by using a formula such as
=SUMIFS(Amount;MPIF;1;YPIF;Sheet1!$B$1)
Approach 3
Not one to recommend, but included for completeness, change your formulae to
=SUMIFS(Amount;DPIF;">=01/01/"&Sheet1!$B$1;DPIF;"<=31/01/"&Sheet1!$B$1)
=SUMIFS(Amount;DPIF;">=01/02/"&Sheet1!$B$1;DPIF;"<=28/02/"&Sheet1!$B$1)
etc
This involves a one-off editing job which will work for years 2021, 2022 and 2023 but will omit 29/02/2024 from February's monthly sum in 2024 unless someone remembers to make a change, and will possibly cause problems in 2025 if not changed back.