Counting Rows Between Two Values and Get Average Number of Rows

chuchuberthelot

New Member
Joined
Mar 2, 2020
Messages
2
Platform
  1. MacOS
Hi Guys,
So what I want to do is count the number of cells between two cell values.

Cell values change; the first cell value range is between 100 and 101, and the second one is between 101 and 102 and so on.

Another problem I'm having is that I have to do this for each student Id and get the average number of cells between 100 and 101, 101 and 102 and so on.

Can anybody (excel experts) help me please.
Screenshot 2020-03-02 05.47.02.png

Screenshot 2020-03-02 05.53.22.png

Thank you so much!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the forum!

In the future, please consider using the XL2BB tool. (See my signature, or the link in the reply box.) When you enter a lot of data in a picture, you force the helpers to manually type in all that data, and many won't bother. With XL2BB, it's just a cut/paste operation.

However, consider this:

Book1
ABCDEFGH
1studentIddatequestionsCoveredexamIdcorrecttotal_num_qsgapavg_gap
210001721201005510012
31000176120  
41000179100101741203 
51000181130  
6100018380  
7100018480  
81000186120102621001 
9100019090  
1010001931101031031401 
111000197130  
121000200110104761004 
131000201130  
141000203120  
15100020490  
161000206100  
17100020760105951202 
18100020990  
19100021270  
2010002149010670904 
211000215120  
22100021780  
231000218110  
241000220110  
25100022190107791000 
26100150901006210001.111111
2710015790101731204 
28100158120  
29100160110  
30100161110  
31100163100  
32100164140102721001 
33100168100  
341001711201031121400 
351001851101051001200 
361001928010676901 
37100196100  
38100199120107851002 
39100110180  
401001104100  
41100110613010877900 
42100111390109991102 
43100111580  
44100111850  
Sheet1
Cell Formulas
RangeFormula
G2:G44G2=IF(E2<>"",IFERROR(AGGREGATE(15,6,ROW(A3:A20)/(A3:A20=A2)/(E3:E20<>""),1)-ROW(A3),COUNTIF(A3:A20,A2)),"")
H2:H44H2=IF(AND(A2<>A1,A2<>""),AVERAGEIF(A:A,A2,G:G),"")


This seems to do what you want. It assumes that the gap will never be more than 18, but that's easy to change if necessary. Let us know.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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