Count diagonal

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Using Excel 2000

Hi,

I am looking VBA that can count 3 diagonals signs "1X2" if the are same then result = 1, if 2 are same 1 is different then result = 2, if 3 are different then result = 3

Step1-Start looking diagonal "1X2" signs in C6, D7, and E8 Find 1, 1, 2 Result 2 in T9
Step2-Start looking diagonal "1X2" signs in D6, E7, and F8 Find 1, X, X Result 2 in U9
Step3-Start looking diagonal "1X2" signs in E6, F7, and G8 Find X, X, 1 Result 2 in V9
Step4-Start looking diagonal "1X2" signs in F6, G7, and H8 Find 1, 1, 1 Result 1 in W9
Check row6 up to N6, O7 and P9

Next step start row 7, 8, 9 and place results in T10:AE10

Note: colour is just to show example clearer...

Example...


Book1
BCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1
2
3
4
5C1C2C3C4C5C6C7C8C9C10C11C12C13C14C1C2C3C4C5C6C7C8C9C10C11C12C13C14
611X1211X111221
721XX1122X12111
82X2X112XX2111X222123321213
91122X221111121221322333121
10X112211XX1X11X
112112X12XX21121
121X212X21X12XX2
13X22121X111112X
14122X2121X1222X
1511211211111121
16
17
18
Sheet1


Thank you in advance

Regards,
Kishan
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
If your diagonals will always be only three cells, you can use the relatively simple formula:

T8: =IF(C6=D7,IF(D7=E8,3,2),IF(OR(C6=E8,D7=E8),2,1))

But if you're going to extend the length of the diagonal (?) I'd be looking to use a smarter and more general formula.
 
Upvote 0
If your diagonals will always be only three cells, you can use the relatively simple formula:

T8: =IF(C6=D7,IF(D7=E8,3,2),IF(OR(C6=E8,D7=E8),2,1))
Hi StephenCrump, thank you very much it is simple but nice formula. To get result as per opening post I did adapted the formula like this way
T8=IF(C6=D7,IF(D7=E8,1,2),IF(OR(C6=E8,D7=E8),2,3))

But if you're going to extend the length of the diagonal (?) I'd be looking to use a smarter and more general formula.
As there are only 3 signs really I have no idea extending the length of the diagonal what results I will get. If you have something in mind you can generalize the formula. I will check it.

Regards,
Kishan
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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