Suppose, you have a square of 8×8 like below
The challenge is following – You need to come up with a formula that sums up the square diagonally. L1 contains the value which tells us how many elements to consider. L2 has T or B (T – from Top, B – from Bottom) which tells us whether the summing up has to be done A1 downwards or H8 upwards. I have put data validation in L1 and L2 (Hence, you would be able to choose only 1 to 8 in L1 and B or T in L2. You can also choose blanks).
If L1=3 and L2 = B, sum would be 29+82+57 (H8 upwards).
If L1=4 and L2 = T, sum would be 76+90+46+37 (A1 downwards).
If L1= Non Blanks, L2 = Blanks – The direction is from Top. Hence L1=2, L2="", sum would be 76+90
If L1= Blanks, L2 = Blanks or Not Blanks, entire diagonal will be summed up. Hence, sum would 76+90+46+37+87+57+82+29.
Excel for the above exercise – Sum of Squares Challenge
Note – You may choose to post the response in comments section.
Hi,
You may see my solution here – http://www.ashishmathur.com/sum-up-diagonal-cells-in-a-range/