How to count events in a calendar year?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,532
Office Version
  1. 365
Platform
  1. Windows
Suppose I have a log of lunches I have attended and I want to find out how many times I had lunch with each person overall and in each year. I was able to get the count of the total number of times, but my formula for the count in a year gets a Spill error.

Any suggestions? Is there a better way? Thanks

Lunch log test.xlsm
BCDEFGHI
3Table Name: TblDatesTable Name: TblNames
4DateName(s)LocationNameTotal20222023
59/15/22Sleepy, GrumpyBrew'd AwakeningBugs Bunny3#SPILL!
68/01/22Scarlet O'Hara, Henrietta Horne, Helen BacqueThai Me UpElbert Wonmug2#SPILL!
77/04/22Henrietta Horne, Scarlet O'HaraLox, Stock, & BagelsFred Flintstone1#SPILL!
86/25/22Helen Bacque, Rhett ButlerWish You Were BeerGrumpy1#SPILL!
96/16/22Bugs BunnyGarden of Eat'nHelen Bacque4#SPILL!
106/05/22Henrietta Horne, Helen BacqueDairy GodmotherHenrietta Horne4#SPILL!
116/03/22Bugs BunnyLettuce Turnip the BeetNeal Andertal1#SPILL!
125/19/22Rhett Butler, Scarlet O'Hara, Pogo PossumCajun DelightPete Moss1#SPILL!
133/01/22Helen BacqueHank's Hot RibsPogo Possum1#SPILL!
141/15/22Pete Moss, Bugs BunnyGarden CenterRhett Butler2#SPILL!
1512/10/21Scarlet O'HaraBread ZeppelinScarlet O'Hara5#SPILL!
168/25/21Scarlet O'HaraAesop's BagelsSleepy1#SPILL!
176/13/21Elbert WonmugAesop's Tables
183/05/21Neal Andertal, Fred Flintstone, Elbert WonmugHard Rock Café
192/03/21Henrietta HorneAwful Annie's
Lunch Tallies
Cell Formulas
RangeFormula
G5:G16G5=COUNTIFS(TblDates[Name(s)],"*" & [@Name] & "*")
H5:H16H5=COUNTIFS(TblDates[Name(s)], "*" & [@Name] & "*", TblDates[Date], YEAR(TblDates[Date])=TblNames[[#Headers],[2022]])
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You misread my comment and in doing so changed my suggested formula in your summarised version.
I was questioning whether there is any harm in deviating from using structured referencing when it doesn't suit ?
I did not use
VALUE(TblNames[[#Headers],[2021]]))
per your summarised version, in my suggestion since that structured reference hard codes the heading column to 2021 (absolute referencing it) so that when you copy it to the next column it doesn't change to 2022, then 2023 in the next etc.

I used
VALUE(H$4)
Only locking in the row but leaving the column as relative so that it could easily be copied across.

Aha! Thanks for that clarification. I did misunderstand your point.
 
Upvote 0
Here is another option.

Excel Formula:
=SUM(FILTER(--ISNUMBER(TblDates[Date]), (YEAR(TblDates[Date])=VALUE(H$4)) * (ISNUMBER(SEARCH([@Name],TblDates[Name(s)]))) ,0) )

I am marking this as the solution. It is the best solution for me.

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,970
Members
449,095
Latest member
Mr Hughes

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