Counting the Range of Cells by comparing its values with the values of another range

gnaga

Well-known Member
Joined
Jul 9, 2002
Messages
748
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Hi All,

I have a two range of cells having an alphabet in each cell (R, M, N, D...)

For ex. Range 1 A10:A41 will have single Alphabet and Range 2 B10:B41 will have single or more than one alphabet (MC, MP,N,R...)

In B9 I need a formula to count number of each unique alphabet in Range 2 for the following condition

Condition
If first cell in Range 1 having R and first cell in Range 2 having any alphabet other than R then take the value as say 12
If Second cell in Range 1 having R and second cell in Range 2 having any alphabet other than R then take the value as say 12 add to the previous 12 and so on until the last cell. Display the final count in B9.

Book1
JKLMNOPQRSTU
6
7RMMDNRRNNRRange 1
832MMMDNRMNNCRange 2
9
10120000012008
Sheet1
Cell Formulas
RangeFormula
J8J8=SUM(K10:T10)
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I need a formula to get the value in J8..
 
Upvote 0
Hi. All

Sorry to very wrongly phrase my question in a hurry. I understand there is no clarity in my previous post on what I wanted. Please find the below part.
Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
112345678910111213141516171819202122232425262728293031Row 1
2RRRRMMNNRRRRMMNNRRRRMMNNRRRRMMNRow 2
3NCMMNNMMMNNMMNNMMMNRow 3
4441200800000012000000000000000012000Row 4
Sheet1
Cell Formulas
RangeFormula
C1:AF1C1=B1+1
A4A4=SUM(B4:AF4)
B4:AF4B4=IF(AND(B2="R",OR(B3="M",B3="N")),12,IF(AND(B2="R",B3="C"),8,0))


Size of the Range for Row 2 and Row 3 will always be same that is 31 entries.
Range Row 3 will have some missing entry while the respective cell in Row 2 is "R"
While the Row 2 cell is "R" and the Row 3 cell is either "M" or "N" value 12 to be taken for meeting this condition.
While the Row 2 cell is "R" and the Row 3 cell is either "C" value 8 to be taken for meeting this condition.
In future these condition may change with different Alphabet in Row 3 and different value while Row 3 cell is "R"

Finally all the values to be added in a cell for which I need a single formula.

Hope I explain my question reasonably clear.
 
Upvote 0
Any clue on this? Probably combination of Index and Match Array Function will do the job. But I need some guidance on how to use them for this specific purpose.
 
Upvote 0
What's wrong with the formulae you've got?
 
Upvote 0
I entered the formula in Row 4 only for explaining what I wanted. I want to bring this result in a single cell (A4) by eliminating the Row 4. Because I have many more other rows of data similar to Row 2 and Row 3 to compare and bring the their result in the corresponding single cell.

I shown here as sample data what the result I wanted.
 
Upvote 0
Ok, how about
Excel Formula:
=SUM(COUNTIFS(B2:AG2,"R",B3:AG3,{"M","N"}))*12+COUNTIFS(B2:AG2,"R",B3:AG3,"C")*8
 
Upvote 0
Thanks Fluff, I will try this and let you know.
 
Upvote 0
Fluff, It works fine. Could you please explain what the curly bracket does in the CountIfs function?
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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