How to reverse the direction of a range in formulas?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
528
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have noticed that every time I have a range in formulas, say A2:D2, Excel takes the range elements from A to D. And if I try to write D2:A2, upon pressing cntrl+shift+enter, Excel auto-corrects it to A2:D2. So I have been trying to look for a way to specify a range such that Excel would consider it in the reverse orientation. Here is a simple example for the formula {=SUM(A1:D1*A2:D2)} which returns the value of 40 assuming the default direction of A2:D2 range:

1575175194597.png


However, the result would be 30 if the direction of A2:D2 was reversed to D2:A2:

1575175397889.png


But could this have been achieved without having to manually rewrite the range in the reverse order? (I'm trying to learn a generic way of doing this so that I can apply it to various situations as I often come across long ranges that have been written in the reverse order and flipping them manually would be cumbersome).

Thanks for any input!!! :)
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
could this have been achieved without having to manually rewrite the range in the reverse order?
Yes it could, but is is not simple and it uses the volatile function OFFSET. See F2 below.

If it was me I would be looking to use a spare range to reverse the order as I have done with A4 copied across and then you can use the simple SUMPRODUCT in F4.

Book1
ABCDEF
11234
2234530
3
4543230
Reverse Range
Cell Formulas
RangeFormula
F2F2=SUMPRODUCT(A1:D1,N(OFFSET(D2,0,COLUMN(A2)-COLUMN(A2:D2))))
A4:D4A4=INDEX($A2:$D2,COLUMNS($A2:$D2)-COLUMNS($A4:A4)+1)
F4F4=SUMPRODUCT(A1:D1,A4:D4)
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0
It can also be done in one cell without using OFFSET,

Book1
ABCDEF
11234
2234530
Sheet7
Cell Formulas
RangeFormula
F2F2=SUMPRODUCT(A1:D1*INDEX(A2:D2,N(IF({1},INDEX(COLUMN(D2)-COLUMN(A2:D2)+1,)))))

The second INDEX function is not strictly necessary, I've only used it to omit the need for array confirmation.
 
Upvote 0
Fantastic! Thanks a lot!!! Also how would it look like without the second INDEX? :)
 
Upvote 0
Another one F2
=SUMPRODUCT(A1:D1,MOD(LARGE(INDEX(COLUMN(A2:D2)*100+A2:D2,),COLUMN(A2:D2)),100))
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,792
Members
449,048
Latest member
greyangel23

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