Is this the best way to calculate the number of events since the last one?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,687
Office Version
  1. 365
Platform
  1. Windows
The minisheet below is my attempt to calculate the number of events (not the number of days) that have occurred since the last time that event occurred.

Col B has the events. Col C has the dates when they have occurred. Cols D & E are parts of the solution. D is the row # of this event. E is the row # of the previous occurrence of that event. Col F puts these together and adds IfError. Is there a better way?

Note: This depends on the table being sorted by date (newest to oldest).

Take Function.xlsx
BCDEFG
3EventDateRow #Row #(Next)# EventsComments
4A6/10/24144Event A last occurred 4 events ago.
5B6/08/24222Event B last occurred 2 events ago.
6C6/05/24333Event C last occurred 3 events ago.
7B6/02/24455Event B last occurred 5 events ago.
8A5/30/245#N/An/aThis is the first time event A occurred.
9C5/25/246#N/An/aThis is the first time event C occurred.
10D5/20/24711Event D last occurred 1 event ago.
11D5/19/248#N/An/aThis is the first time event D occurred.
12B5/10/249#N/An/aThis is the first time event B occurred.
Count Between
Cell Formulas
RangeFormula
D4:D12D4=ROW()-ROW(Table4[[#Headers],[Event]])
E4:E12E4=MATCH([@Event],DROP([Event],[@[Row '#]]),0)
F4:F12F4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
工作簿1.xlsx
ABCDEFGH
1
2
3EventDateRow #Row #(Next)# EventsComments
4A2024-6-104Event A last occurred 4 events ago.
5B2024-6-82Event B last occurred 2 events ago.
6C2024-6-53Event C last occurred 3 events ago.
7B2024-6-25Event B last occurred 5 events ago.
8A2024-5-30n/aThis is the first time event A occurred.
9C2024-5-25n/aThis is the first time event C occurred.
10D2024-5-201Event D last occurred 1 event ago.
11D2024-5-19n/aThis is the first time event D occurred.
12B2024-5-10n/aThis is the first time event B occurred.
13
Sheet1
Cell Formulas
RangeFormula
F4:F12F4=IFNA(MATCH(B4,B5:B23,),"n/a")
 
Upvote 0
Hmmm... I was puzzled when I saw that your solution used sheet cell references rather than table cell references. Is your data in a table? Mine is.

I added your formula to my table and was surprised to see that it got the same answers. But then I noticed that your formulas are not the same in each row. The match range extends below the table. So I added an event letter undeneath the table and, as you can see below, it affects the match resulting in an incorrect result. My formula is not affected. I also experimented with adding rows in various locations. This also caused your formula problems.

This all leads me to ask if this "solution" might have come from some AI bot.

Cell Formulas
RangeFormula
D4:D12D4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
E4E4=IFNA(MATCH(B4,B5:B$12,),"n/a")
F4:F12F4=FORMULATEXT([@[shaowu Solution]])
E5:E12E5=IFNA(MATCH(B5,B6:B13,),"n/a")
 
Upvote 0
Ok. I've done a little more testing. The minisheet below shows my original (Match) solution plus the same solution using XMatch. They both get correct answers if I add a row to the top, middle, or end of the table. The old values (before adding rows) are in the Old Values column. The cells before adding the new rows are greyed out. The ones that were changed are highlighted in yellow. I also included a column for shaowu's solution. It gets the wrong asnwer several times.

I have a couple of questions:
  1. Is there any reason to use XMatch rather than Match?
  2. Is there many reason to use IFNA rather than IFERROR?
  3. Is there a better way do this?
Thanks

XMatch Function.xlsx
BCDEFGH
3EventDateOld ValuesMatch SolutionXMatch SolutionCommentsshaowu Solution
4C6/11/2444New C event add at top of table4
5A6/10/24455Result of adding D event in middle of table5
6B6/08/24233Result of adding D event in middle of table2
7D6/07/2455New D event added in middle of table5
8C6/05/243333
9B6/02/245555
10A5/30/24n/a55Result of adding A event at end5
11C5/25/24n/an/an/an/a
12D5/20/241111
13D5/19/24n/an/an/an/a
14B5/10/24n/an/an/a2
15A5/06/24n/an/aNew A event added at end of tablen/a
16
17B
Count Between
Cell Formulas
RangeFormula
E4:E15E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F15F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
H4,H7:H13H4=IFNA(MATCH(B4,B5:B13,),"n/a")
H5H5=IFNA(MATCH(B5,B6:B$14,),"n/a")
H6H6=IFNA(MATCH(B6,B8:B16,),"n/a")
H14H14=IFNA(MATCH(B14,B16:B23,),"n/a")
H15H15=IFNA(MATCH(B15,B16:B23,),"n/a")
 
Upvote 0
In shaowu's solution, the end of the range that started out as "B12" increasesd in each sunsequent row. I thought I'd see what happens if I change that to B$12. That makes it even worse.

Can anyone explain why H7, highlighted in red, is "1"?

XMatch Function.xlsx
BCDEFGHI
3EventDateOld ValuesMatch SolutionXMatch Solutionshaowu Solution1shaowu Solution2Comments
4A6/10/2444444
5B6/08/2422222
6C6/05/2433333
7B6/02/2455551Why is this "1"?
8A5/30/24n/an/an/an/an/a
9C5/25/24n/an/an/an/an/a
10D5/20/2411111
11D5/19/24n/an/an/an/a1
12B5/10/24n/an/an/a21
13
14BEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E12E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F12F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4:G12G4=IFNA(MATCH(B4,B5:B12,),"n/a")
H4:H11H4=IFNA(MATCH(B4,B5:B$12),"n/a")
H12H12=IFNA(MATCH(B12,B$12:B13),"n/a")
 
Upvote 0
In shaowu's solution, the end of the range that started out as "B12" increasesd in each sunsequent row. I thought I'd see what happens if I change that to B$12. That makes it even worse.

Can anyone explain why H7, highlighted in red, is "1"?

XMatch Function.xlsx
BCDEFGHI
3EventDateOld ValuesMatch SolutionXMatch Solutionshaowu Solution1shaowu Solution2Comments
4A6/10/2444444
5B6/08/2422222
6C6/05/2433333
7B6/02/2455551Why is this "1"?
8A5/30/24n/an/an/an/an/a
9C5/25/24n/an/an/an/an/a
10D5/20/2411111
11D5/19/24n/an/an/an/a1
12B5/10/24n/an/an/a21
13
14BEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E12E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F12F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4:G12G4=IFNA(MATCH(B4,B5:B12,),"n/a")
H4:H11H4=IFNA(MATCH(B4,B5:B$12),"n/a")
H12H12=IFNA(MATCH(B12,B$12:B13),"n/a")
you lost "," in MATCH.
H4=IFNA(MATCH(B4,B5:B$13,),"n/a")
 
Upvote 0
you lost "," in MATCH.
H4=IFNA(MATCH(B4,B5:B$13,),"n/a")
You are right about that. The default for the XMatch match_mode parameter is 0. I assumed it was the same for Match. I have corrected that, but it only solves part of the problem. I also added 2 new columns with XMatch replacing Match. They have similar problems. Errors highlighted in yellow.

XMatch Function.xlsx
BCDEFGHIJK
3EventDateOld ValuesMatch Solution(Best) XMatch SolutionRalative Range w/MatchAbsolute Range w/MatchRalative Range w/XMatchAbsolute Range w/XMatchComments
4A6/10/244444444
5B6/08/242222222
6C6/05/243333333
7B6/02/245555555
8A5/30/24n/an/an/a6n/a6n/a
9C5/25/24n/an/an/a9n/an/an/a
10D5/20/241111111
11D5/19/24n/an/an/a9n/an/an/a
12B5/10/24n/an/an/a3141
13
14AEvent text added outside table
15
16BEvent text added outside table
17
18CEvent text added outside table
19
20DEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E12E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F12F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4G4=IFNA(MATCH(B4,B5:B12,0),"n/a")
H4:H11H4=IFNA(MATCH(B4,B5:B$12,0),"n/a")
I4:I12I4=IFNA(XMATCH(B4,B5:B12,0),"n/a")
J4:J11J4=IFNA(XMATCH(B4,B5:B$12,0),"n/a")
G5G5=IFNA(MATCH(B5,B6:B14,0),"n/a")
G6:G8G6=IFNA(MATCH(B6,B7:B16,0),"n/a")
G9:G11G9=IFNA(MATCH(B9,B10:B20,0),"n/a")
G12G12=IFNA(MATCH(B12,B14:B23,0),"n/a")
H12H12=IFNA(MATCH(B12,B$12:B13,0),"n/a")
J12J12=IFNA(XMATCH(B12,B$12:B13,0),"n/a")


Then I added a few rows to the table. This caused even more problems for your solutions. Mine continue to work correctly.

XMatch Function.xlsx
BCDEFGHIJK
3EventDateOld Values(Good) Match Solution(Best) XMatch Solution(Fails) Ralative Range w/Match(Fails) Absolute Range w/Match(Fails) Ralative Range w/XMatch(Fails) Absolute Range w/XMatchComments
4D6/11/24888888New row 1
5A6/10/244333333
6B6/08/242333333
7C6/05/243443333
8A6/04/24222222New row in niddle
9B6/02/245555555
10A5/30/24n/a555n/a5n/a
11C5/25/24n/an/an/a10n/an/an/a
12D5/20/241111111
13D5/19/24n/an/an/a10n/an/an/a
14B5/10/24n/an/an/a3141
15A5/05/24n/an/a2323New last row
16
17AEvent text added outside table
18
19BEvent text added outside table
20
21CEvent text added outside table
22
23DEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E15E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F15F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4:G5,G15G4=IFNA(MATCH(B4,B5:B13,0),"n/a")
H4,H8H4=IFNA(MATCH(B4,B5:B$13,),"n/a")
I4:I5,I9:I13,I15I4=IFNA(XMATCH(B4,B5:B13,0),"n/a")
J4,J8J4=IFNA(XMATCH(B4,B5:B$13,0),"n/a")
H5:H6,H9:H13H5=IFNA(MATCH(B5,B6:B$14,0),"n/a")
J5:J6,J9:J13J5=IFNA(XMATCH(B5,B6:B$14,0),"n/a")
G6,G9:G10G6=IFNA(MATCH(B6,B7:B17,0),"n/a")
I6,I8I6=IFNA(XMATCH(B6,B7:B16,0),"n/a")
G7G7=IFNA(MATCH(B7,B9:B19,0),"n/a")
H7H7=IFNA(MATCH(B7,B9:B$14,0),"n/a")
I7I7=IFNA(XMATCH(B7,B9:B17,0),"n/a")
J7J7=IFNA(XMATCH(B7,B9:B$14,0),"n/a")
G8G8=IFNA(MATCH(B8,B9:B18,0),"n/a")
G11:G13G11=IFNA(MATCH(B11,B12:B23,0),"n/a")
G14G14=IFNA(MATCH(B14,B17:B26,0),"n/a")
H14H14=IFNA(MATCH(B14,B$14:B16,0),"n/a")
I14I14=IFNA(XMATCH(B14,B16:B23,0),"n/a")
J14J14=IFNA(XMATCH(B14,B$14:B16,0),"n/a")
H15H15=IFNA(MATCH(B15,B$13:B16,),"n/a")
J15J15=IFNA(XMATCH(B15,B$13:B16,0),"n/a")


I am curious as to why you mentioned my error on the match_mode paraneter, but have said nothing about the many errors with your solution. And even with the parameter error, you said nothing but the omission. Are you sure this is not something you got from an AI bot and you really don't understand it? You do know that the use of AI bots is prohibited here, right?
 
Upvote 0
You are right about that. The default for the XMatch match_mode parameter is 0. I assumed it was the same for Match. I have corrected that, but it only solves part of the problem. I also added 2 new columns with XMatch replacing Match. They have similar problems. Errors highlighted in yellow.

XMatch Function.xlsx
BCDEFGHIJK
3EventDateOld ValuesMatch Solution(Best) XMatch SolutionRalative Range w/MatchAbsolute Range w/MatchRalative Range w/XMatchAbsolute Range w/XMatchComments
4A6/10/244444444
5B6/08/242222222
6C6/05/243333333
7B6/02/245555555
8A5/30/24n/an/an/a6n/a6n/a
9C5/25/24n/an/an/a9n/an/an/a
10D5/20/241111111
11D5/19/24n/an/an/a9n/an/an/a
12B5/10/24n/an/an/a3141
13
14AEvent text added outside table
15
16BEvent text added outside table
17
18CEvent text added outside table
19
20DEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E12E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F12F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4G4=IFNA(MATCH(B4,B5:B12,0),"n/a")
H4:H11H4=IFNA(MATCH(B4,B5:B$12,0),"n/a")
I4:I12I4=IFNA(XMATCH(B4,B5:B12,0),"n/a")
J4:J11J4=IFNA(XMATCH(B4,B5:B$12,0),"n/a")
G5G5=IFNA(MATCH(B5,B6:B14,0),"n/a")
G6:G8G6=IFNA(MATCH(B6,B7:B16,0),"n/a")
G9:G11G9=IFNA(MATCH(B9,B10:B20,0),"n/a")
G12G12=IFNA(MATCH(B12,B14:B23,0),"n/a")
H12H12=IFNA(MATCH(B12,B$12:B13,0),"n/a")
J12J12=IFNA(XMATCH(B12,B$12:B13,0),"n/a")


Then I added a few rows to the table. This caused even more problems for your solutions. Mine continue to work correctly.

XMatch Function.xlsx
BCDEFGHIJK
3EventDateOld Values(Good) Match Solution(Best) XMatch Solution(Fails) Ralative Range w/Match(Fails) Absolute Range w/Match(Fails) Ralative Range w/XMatch(Fails) Absolute Range w/XMatchComments
4D6/11/24888888New row 1
5A6/10/244333333
6B6/08/242333333
7C6/05/243443333
8A6/04/24222222New row in niddle
9B6/02/245555555
10A5/30/24n/a555n/a5n/a
11C5/25/24n/an/an/a10n/an/an/a
12D5/20/241111111
13D5/19/24n/an/an/a10n/an/an/a
14B5/10/24n/an/an/a3141
15A5/05/24n/an/a2323New last row
16
17AEvent text added outside table
18
19BEvent text added outside table
20
21CEvent text added outside table
22
23DEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E15E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F15F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4:G5,G15G4=IFNA(MATCH(B4,B5:B13,0),"n/a")
H4,H8H4=IFNA(MATCH(B4,B5:B$13,),"n/a")
I4:I5,I9:I13,I15I4=IFNA(XMATCH(B4,B5:B13,0),"n/a")
J4,J8J4=IFNA(XMATCH(B4,B5:B$13,0),"n/a")
H5:H6,H9:H13H5=IFNA(MATCH(B5,B6:B$14,0),"n/a")
J5:J6,J9:J13J5=IFNA(XMATCH(B5,B6:B$14,0),"n/a")
G6,G9:G10G6=IFNA(MATCH(B6,B7:B17,0),"n/a")
I6,I8I6=IFNA(XMATCH(B6,B7:B16,0),"n/a")
G7G7=IFNA(MATCH(B7,B9:B19,0),"n/a")
H7H7=IFNA(MATCH(B7,B9:B$14,0),"n/a")
I7I7=IFNA(XMATCH(B7,B9:B17,0),"n/a")
J7J7=IFNA(XMATCH(B7,B9:B$14,0),"n/a")
G8G8=IFNA(MATCH(B8,B9:B18,0),"n/a")
G11:G13G11=IFNA(MATCH(B11,B12:B23,0),"n/a")
G14G14=IFNA(MATCH(B14,B17:B26,0),"n/a")
H14H14=IFNA(MATCH(B14,B$14:B16,0),"n/a")
I14I14=IFNA(XMATCH(B14,B16:B23,0),"n/a")
J14J14=IFNA(XMATCH(B14,B$14:B16,0),"n/a")
H15H15=IFNA(MATCH(B15,B$13:B16,),"n/a")
J15J15=IFNA(XMATCH(B15,B$13:B16,0),"n/a")


I am curious as to why you mentioned my error on the match_mode paraneter, but have said nothing about the many errors with your solution. And even with the parameter error, you said nothing but the omission. Are you sure this is not something you got from an AI bot and you really don't understand it? You do know that the use of AI bots is prohibited here, right?
please refer to my post #6, the formula is:
H4=IFNA(MATCH(B4,B5:B$13,),"n/a")
copy and paste above formula in H4.
 
Upvote 0
You are right about that. The default for the XMatch match_mode parameter is 0. I assumed it was the same for Match. I have corrected that, but it only solves part of the problem. I also added 2 new columns with XMatch replacing Match. They have similar problems. Errors highlighted in yellow.

XMatch Function.xlsx
BCDEFGHIJK
3EventDateOld ValuesMatch Solution(Best) XMatch SolutionRalative Range w/MatchAbsolute Range w/MatchRalative Range w/XMatchAbsolute Range w/XMatchComments
4A6/10/244444444
5B6/08/242222222
6C6/05/243333333
7B6/02/245555555
8A5/30/24n/an/an/a6n/a6n/a
9C5/25/24n/an/an/a9n/an/an/a
10D5/20/241111111
11D5/19/24n/an/an/a9n/an/an/a
12B5/10/24n/an/an/a3141
13
14AEvent text added outside table
15
16BEvent text added outside table
17
18CEvent text added outside table
19
20DEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E12E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F12F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4G4=IFNA(MATCH(B4,B5:B12,0),"n/a")
H4:H11H4=IFNA(MATCH(B4,B5:B$12,0),"n/a")
I4:I12I4=IFNA(XMATCH(B4,B5:B12,0),"n/a")
J4:J11J4=IFNA(XMATCH(B4,B5:B$12,0),"n/a")
G5G5=IFNA(MATCH(B5,B6:B14,0),"n/a")
G6:G8G6=IFNA(MATCH(B6,B7:B16,0),"n/a")
G9:G11G9=IFNA(MATCH(B9,B10:B20,0),"n/a")
G12G12=IFNA(MATCH(B12,B14:B23,0),"n/a")
H12H12=IFNA(MATCH(B12,B$12:B13,0),"n/a")
J12J12=IFNA(XMATCH(B12,B$12:B13,0),"n/a")


Then I added a few rows to the table. This caused even more problems for your solutions. Mine continue to work correctly.

XMatch Function.xlsx
BCDEFGHIJK
3EventDateOld Values(Good) Match Solution(Best) XMatch Solution(Fails) Ralative Range w/Match(Fails) Absolute Range w/Match(Fails) Ralative Range w/XMatch(Fails) Absolute Range w/XMatchComments
4D6/11/24888888New row 1
5A6/10/244333333
6B6/08/242333333
7C6/05/243443333
8A6/04/24222222New row in niddle
9B6/02/245555555
10A5/30/24n/a555n/a5n/a
11C5/25/24n/an/an/a10n/an/an/a
12D5/20/241111111
13D5/19/24n/an/an/a10n/an/an/a
14B5/10/24n/an/an/a3141
15A5/05/24n/an/a2323New last row
16
17AEvent text added outside table
18
19BEvent text added outside table
20
21CEvent text added outside table
22
23DEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E15E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F15F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4:G5,G15G4=IFNA(MATCH(B4,B5:B13,0),"n/a")
H4,H8H4=IFNA(MATCH(B4,B5:B$13,),"n/a")
I4:I5,I9:I13,I15I4=IFNA(XMATCH(B4,B5:B13,0),"n/a")
J4,J8J4=IFNA(XMATCH(B4,B5:B$13,0),"n/a")
H5:H6,H9:H13H5=IFNA(MATCH(B5,B6:B$14,0),"n/a")
J5:J6,J9:J13J5=IFNA(XMATCH(B5,B6:B$14,0),"n/a")
G6,G9:G10G6=IFNA(MATCH(B6,B7:B17,0),"n/a")
I6,I8I6=IFNA(XMATCH(B6,B7:B16,0),"n/a")
G7G7=IFNA(MATCH(B7,B9:B19,0),"n/a")
H7H7=IFNA(MATCH(B7,B9:B$14,0),"n/a")
I7I7=IFNA(XMATCH(B7,B9:B17,0),"n/a")
J7J7=IFNA(XMATCH(B7,B9:B$14,0),"n/a")
G8G8=IFNA(MATCH(B8,B9:B18,0),"n/a")
G11:G13G11=IFNA(MATCH(B11,B12:B23,0),"n/a")
G14G14=IFNA(MATCH(B14,B17:B26,0),"n/a")
H14H14=IFNA(MATCH(B14,B$14:B16,0),"n/a")
I14I14=IFNA(XMATCH(B14,B16:B23,0),"n/a")
J14J14=IFNA(XMATCH(B14,B$14:B16,0),"n/a")
H15H15=IFNA(MATCH(B15,B$13:B16,),"n/a")
J15J15=IFNA(XMATCH(B15,B$13:B16,0),"n/a")


I am curious as to why you mentioned my error on the match_mode paraneter, but have said nothing about the many errors with your solution. And even with the parameter error, you said nothing but the omission. Are you sure this is not something you got from an AI bot and you really don't understand it? You do know that the use of AI bots is prohibited here, right?
i am not an english speaker, it is hard for me to explain every thing in english. i made the formula by my self, your issue is not a difficult one, just a common match thing. if you have a translate machine, i can explain your questions in detail.
 
Upvote 0
You are right about that. The default for the XMatch match_mode parameter is 0. I assumed it was the same for Match. I have corrected that, but it only solves part of the problem. I also added 2 new columns with XMatch replacing Match. They have similar problems. Errors highlighted in yellow.

XMatch Function.xlsx
BCDEFGHIJK
3EventDateOld ValuesMatch Solution(Best) XMatch SolutionRalative Range w/MatchAbsolute Range w/MatchRalative Range w/XMatchAbsolute Range w/XMatchComments
4A6/10/244444444
5B6/08/242222222
6C6/05/243333333
7B6/02/245555555
8A5/30/24n/an/an/a6n/a6n/a
9C5/25/24n/an/an/a9n/an/an/a
10D5/20/241111111
11D5/19/24n/an/an/a9n/an/an/a
12B5/10/24n/an/an/a3141
13
14AEvent text added outside table
15
16BEvent text added outside table
17
18CEvent text added outside table
19
20DEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E12E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F12F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4G4=IFNA(MATCH(B4,B5:B12,0),"n/a")
H4:H11H4=IFNA(MATCH(B4,B5:B$12,0),"n/a")
I4:I12I4=IFNA(XMATCH(B4,B5:B12,0),"n/a")
J4:J11J4=IFNA(XMATCH(B4,B5:B$12,0),"n/a")
G5G5=IFNA(MATCH(B5,B6:B14,0),"n/a")
G6:G8G6=IFNA(MATCH(B6,B7:B16,0),"n/a")
G9:G11G9=IFNA(MATCH(B9,B10:B20,0),"n/a")
G12G12=IFNA(MATCH(B12,B14:B23,0),"n/a")
H12H12=IFNA(MATCH(B12,B$12:B13,0),"n/a")
J12J12=IFNA(XMATCH(B12,B$12:B13,0),"n/a")


Then I added a few rows to the table. This caused even more problems for your solutions. Mine continue to work correctly.

XMatch Function.xlsx
BCDEFGHIJK
3EventDateOld Values(Good) Match Solution(Best) XMatch Solution(Fails) Ralative Range w/Match(Fails) Absolute Range w/Match(Fails) Ralative Range w/XMatch(Fails) Absolute Range w/XMatchComments
4D6/11/24888888New row 1
5A6/10/244333333
6B6/08/242333333
7C6/05/243443333
8A6/04/24222222New row in niddle
9B6/02/245555555
10A5/30/24n/a555n/a5n/a
11C5/25/24n/an/an/a10n/an/an/a
12D5/20/241111111
13D5/19/24n/an/an/a10n/an/an/a
14B5/10/24n/an/an/a3141
15A5/05/24n/an/a2323New last row
16
17AEvent text added outside table
18
19BEvent text added outside table
20
21CEvent text added outside table
22
23DEvent text added outside table
Count Between
Cell Formulas
RangeFormula
E4:E15E4=IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
F4:F15F4=IFERROR(XMATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a")
G4:G5,G15G4=IFNA(MATCH(B4,B5:B13,0),"n/a")
H4,H8H4=IFNA(MATCH(B4,B5:B$13,),"n/a")
I4:I5,I9:I13,I15I4=IFNA(XMATCH(B4,B5:B13,0),"n/a")
J4,J8J4=IFNA(XMATCH(B4,B5:B$13,0),"n/a")
H5:H6,H9:H13H5=IFNA(MATCH(B5,B6:B$14,0),"n/a")
J5:J6,J9:J13J5=IFNA(XMATCH(B5,B6:B$14,0),"n/a")
G6,G9:G10G6=IFNA(MATCH(B6,B7:B17,0),"n/a")
I6,I8I6=IFNA(XMATCH(B6,B7:B16,0),"n/a")
G7G7=IFNA(MATCH(B7,B9:B19,0),"n/a")
H7H7=IFNA(MATCH(B7,B9:B$14,0),"n/a")
I7I7=IFNA(XMATCH(B7,B9:B17,0),"n/a")
J7J7=IFNA(XMATCH(B7,B9:B$14,0),"n/a")
G8G8=IFNA(MATCH(B8,B9:B18,0),"n/a")
G11:G13G11=IFNA(MATCH(B11,B12:B23,0),"n/a")
G14G14=IFNA(MATCH(B14,B17:B26,0),"n/a")
H14H14=IFNA(MATCH(B14,B$14:B16,0),"n/a")
I14I14=IFNA(XMATCH(B14,B16:B23,0),"n/a")
J14J14=IFNA(XMATCH(B14,B$14:B16,0),"n/a")
H15H15=IFNA(MATCH(B15,B$13:B16,),"n/a")
J15J15=IFNA(XMATCH(B15,B$13:B16,0),"n/a")


I am curious as to why you mentioned my error on the match_mode paraneter, but have said nothing about the many errors with your solution. And even with the parameter error, you said nothing but the omission. Are you sure this is not something you got from an AI bot and you really don't understand it? You do know that the use of AI bots is prohibited here, right?
further more, you can see my other post, i don't think ai could generate such proper solutions.
 
Upvote 0

Forum statistics

Threads
1,223,954
Messages
6,175,601
Members
452,658
Latest member
GStorm

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