Counting numbers after specific numbers

AugustGraham

New Member
Joined
Jul 13, 2011
Messages
5
Hello,

I'm currently faced with a problem I simply cannot solve. I have a list of data with numbers between 1 and 3 which looks something like this: {3,2,2,3,1,1,2,3,1,3,2,1,2,3,1,2,3,1,2,2,3,1,3,2,3,1,2,2,3,1,3,2,1,3,1} (but hundreds more numbers).

Anyway, what I want to do is count how many 3's are followed by 2's (4 in the example given above).

If anyone could help I'd be most grateful.
Thanks in advance.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hello,

I'm currently faced with a problem I simply cannot solve. I have a list of data with numbers between 1 and 3 which looks something like this: {3,2,2,3,1,1,2,3,1,3,2,1,2,3,1,2,3,1,2,2,3,1,3,2,3,1,2,2,3,1,3,2,1,3,1} (but hundreds more numbers).

Anyway, what I want to do is count how many 3's are followed by 2's (4 in the example given above).

If anyone could help I'd be most grateful.
Thanks in advance.
Try this...

=SUMPRODUCT(--(A2:A35=3),--(A3:A36=2))

Note how the ranges are offset.
 
Upvote 0
Thanks very much for the quick response. However I could not get it to work. it says Err:508.
Thanks anyway.
That's not an Excel error message.

A quick Google search says it's from Open Office.

I don't know anything about Open Office. Does it support array formulas?

See if this works...

Array entered**:

=SUM(IF(A2:A35=3,IF(A3:A36=2,1)))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
 
Upvote 0
That's not an Excel error message.

A quick Google search says it's from Open Office.

I don't know anything about Open Office. Does it support array formulas?

See if this works...

Array entered**:

=SUM(IF(A2:A35=3,IF(A3:A36=2,1)))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Sorry, I completely forgot I was on Open Office. I've got another PC which I use more often which has Excel but I don't have access to that until tomorrow, I'll try the formulas you gave me on that.
Thanks very much for your time and effort, and if it works thanks very much for doing me a huge favour.
Night-night (for us Europeans).
 
Upvote 0
Sorry, I completely forgot I was on Open Office. I've got another PC which I use more often which has Excel but I don't have access to that until tomorrow, I'll try the formulas you gave me on that.
Thanks very much for your time and effort, and if it works thanks very much for doing me a huge favour.
Night-night (for us Europeans).
You're welcome. Thanks for the feedback! :cool:
 
Upvote 0
You're welcome. Thanks for the feedback! :cool:

I tried it now on my desktop (which actually has Excel, not just Open Office) and it worked brilliantly. Thanks a million times over. Although I did have to change the comma you put in the middle into a semicolon (;), but I've got the Swedish version of Excel, that could be the reason.
Cheers and thanks and thanks and cheers.
/August
 
Upvote 0
I tried it now on my desktop (which actually has Excel, not just Open Office) and it worked brilliantly. Thanks a million times over. Although I did have to change the comma you put in the middle into a semicolon (;), but I've got the Swedish version of Excel, that could be the reason.
Cheers and thanks and thanks and cheers.
/August

Haha, they just changed my semicolon to a smiley. I meant to write ( ; ) not (;).
 
Upvote 0
I tried it now on my desktop (which actually has Excel, not just Open Office) and it worked brilliantly. Thanks a million times over. Although I did have to change the comma you put in the middle into a semicolon (;), but I've got the Swedish version of Excel, that could be the reason.
Cheers and thanks and thanks and cheers.
/August
Good deal. Thanks for feeding back! :cool:
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

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