Excel conditional functions

Joely_0523

New Member
Joined
Jan 24, 2013
Messages
8
Hi all -

I need to use "countif" functions for rows with certain values that work in multiples of 5. It's a bit complicated but I need to figure out a macro or short script I can run that counts occurences just for a select number of rows.

i.e.
A B C
47000
410U11
40001
40001
40001
40001
40001
40001
40001
40001
00301
00101
40001
410R12
40002
40002
410R13
40003
410B14
40004
410B15
40005
410B16
40006
410R17
460P07
40007
410U18
40008
410R19
40009
410B110
400010

<colgroup><col style="width:48pt" span="3" width="64"> </colgroup><tbody>
</tbody>
So I need to run count if statements for every multiple of 5. I can not simply use the same number of rows, as it changes. I am trying to figure out how many 410 codes I have for every 5, and then do averages for those buckets of 5.


Any help is greatly appreciated!

<colgroup><col><col span="2"></colgroup><tbody>
</tbody>
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Welcome to MrExcel!

If I understand correctly, if your data (where the 410s are) resides in A2:A34, try:

Code:
=IF(MOD((ROWS(A$2:A2)-1),5)+1=5,SUM(IF(LEFT(A$2:A2,3)="410",1))-SUM(C$1:C1),"")

In C2, committed with CTRL+SHIFT+ENTER and copied down.

Is this what you were after?

Matty
 
Upvote 0
I don't think that's exactly what I'm looking for. If we look at column C, I only want the rows that go up to value 5 (because I'm doing this in multiples of 5). In this case, 1-5 in column C ends at row 22. So for rows 1-22, I want to do a countif function for the 410s. So everytime I get a 410 in occurences 1-5, I want a frequency count. Then I need this to start again for rows 22 to 33 (where 6-10 happen, as this is my next multiple of 5). Does that make sense?
 
Upvote 0
I don't think that's exactly what I'm looking for. If we look at column C, I only want the rows that go up to value 5 (because I'm doing this in multiples of 5). In this case, 1-5 in column C ends at row 22. So for rows 1-22, I want to do a countif function for the 410s. So everytime I get a 410 in occurences 1-5, I want a frequency count. Then I need this to start again for rows 22 to 33 (where 6-10 happen, as this is my next multiple of 5). Does that make sense?

Sorry, but I'm not sure I follow.

What do you mean by a "frequency count"?

It might be best if you show us exactly what you want the formula to deliver in a separate column. Could you post an illustrative example?

Matty
 
Upvote 0
Sure, so in the example 410s refer to our code for throws. 410R = strong throw, 410Y = medium throw, 410B = weak throw, 410U = unsuccessful throw. So I have a countif statement to return a 1 if a "410" is found (column B). Then I summed those to count how many times I see the "410" code (column C). Now, I am making averages for ever 5 throws of strong, medium, weak, unsuccessful. I need to figure out how to count the number of 410R, 410Y, etc. for every 5 times I see a 410 code (hence the multiple of 5 part).

Hope this makes sense but it's a bit tricky!

40000TimeThrow AttemptsThrow Unsuccess
Throw SuccessStrongMediumWeak
410U111514202
40001
40001
40001
40001
40001
40001
40001
40001
00301
00101
40001
410R12
40002
40002
40002
40002
40002
410R13
40003
410B14
40004
40004
410B15
40005
410B16TimeThrow AttemptsThrow UnsuccessThrow SuccessStrongMediumWeak
4000621046402
410R17
460P07
43007
00307
47007
00107
48007
42007
40007
410U18
40008
410R19
40009
410B110
400010
410R111TimeThrow AttemptsThrow UnsuccessThrow SuccessStrongMediumWeak
40001131037421
400011
410U112
400012
410U113
400013
410U114
400014
410R115
400015

<colgroup><col><col span="5"><col><col span="3"></colgroup><tbody>
</tbody>
 
Upvote 0
The layout is slightly different, but is the following acceptable?

Layout as follows...

*ABCDEFGH
1Throw TypeTimeThrow AttemptsThrow UnsuccessfulThrow SuccessStrongMediumWeak
2400*******
3410U*******
4400*******
5400*******
6400*******
7400*******
8400*******
9400*******
10400*******
11400*******
123*******
131*******
14400*******
15410R*******
16400*******
17400*******
18400*******
19400*******
20400*******
21410R*******
22400*******
23410B*******
24400*******
25400*******
26410B1514202
27400*******
28410B*******
29400*******
30410R*******
31460P*******
32430*******
333*******
34470*******
351*******
36480*******
37420*******
38400*******
39410U*******
40400*******
41410R*******
42400*******
43410B21019202
44400*******
45410R*******
46400*******
47400*******
48410U*******
49400*******
50410U*******
51400*******
52410U*******
53400*******
54410R315312200
55400*******

<tbody>
</tbody>

Formulas as follows...

B2, copied down:

Code:
=IF(C2<>"",COUNT(C$2:C2),"")

C2, committed with CTRL+SHIFT+ENTER and copied down:

Code:
=IF(AND(LEFT(A1,3)<>"410",LEFT(A2,3)="410",MOD((SUM(IF(LEFT(A$2:A2,3)="410",1))-1),5)+1=5),SUM(IF(LEFT(A$2:A2,3)="410",1)),"")

D2, committed with CTRL+SHIFT+ENTER and copied down:

Code:
=IF(C2<>"",SUM(IF(A$2:A2="410U",1))-SUM(D$1:D1),"")

E2, copied down:

Code:
=IF(B2<>"",C2-D2,"")

F2, copied down:

Code:
=IF(C2<>"",COUNTIF(A$2:A2,"410R")-SUM(F$1:F1),"")

G2, copied down:

Code:
=IF(C2<>"",COUNTIF(A$2:A2,"410Y")-SUM(G$1:G1),"")

H2, copied down:
Code:
=IF(C2<>"",COUNTIF(A$2:A2,"410B")-SUM(H$1:H1),"")

Matty
 
Upvote 0
The layout is slightly different, but is the following acceptable?

Layout as follows...

*ABCDEFGH
1Throw TypeTimeThrow AttemptsThrow UnsuccessfulThrow SuccessStrongMediumWeak
2400*******
3410U*******
4400*******
5400*******
6400*******
7400*******
8400*******
9400*******
10400*******
11400*******
123*******
131*******
14400*******
15410R*******
16400*******
17400*******
18400*******
19400*******
20400*******
21410R*******
22400*******
23410B*******
24400*******
25400*******
26410B1514202
27400*******
28410B*******
29400*******
30410R*******
31460P*******
32430*******
333*******
34470*******
351*******
36480*******
37420*******
38400*******
39410U*******
40400*******
41410R*******
42400*******
43410B21019202
44400*******
45410R*******
46400*******
47400*******
48410U*******
49400*******
50410U*******
51400*******
52410U*******
53400*******
54410R315312200
55400*******

<tbody>
</tbody>

Formulas as follows...

B2, copied down:

Code:
=IF(C2<>"",COUNT(C$2:C2),"")

C2, committed with CTRL+SHIFT+ENTER and copied down:

Code:
=IF(AND(LEFT(A1,3)<>"410",LEFT(A2,3)="410",MOD((SUM(IF(LEFT(A$2:A2,3)="410",1))-1),5)+1=5),SUM(IF(LEFT(A$2:A2,3)="410",1)),"")

D2, committed with CTRL+SHIFT+ENTER and copied down:

Code:
=IF(C2<>"",SUM(IF(A$2:A2="410U",1))-SUM(D$1:D1),"")

E2, copied down:

Code:
=IF(B2<>"",C2-D2,"")

F2, copied down:

Code:
=IF(C2<>"",COUNTIF(A$2:A2,"410R")-SUM(F$1:F1),"")

G2, copied down:

Code:
=IF(C2<>"",COUNTIF(A$2:A2,"410Y")-SUM(G$1:G1),"")

H2, copied down:
Code:
=IF(C2<>"",COUNTIF(A$2:A2,"410B")-SUM(H$1:H1),"")

Matty



Ah sorry for the delay Matty! That seemed to work out pretty well though. I really appreciate your help!
 
Upvote 0
Ah sorry for the delay Matty! That seemed to work out pretty well though. I really appreciate your help!

No problem. Glad I could help!

Matty
 
Upvote 0

Forum statistics

Threads
1,215,410
Messages
6,124,755
Members
449,187
Latest member
hermansoa

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