In last tip, I covered how to reverse a single range. Here, I am going to cover how to reverse multiple ranges.
The formula which can be used here to reverse multiple columns (here range is A2:C12)
=LET(r, A2:C12, IFERROR(DROP(REDUCE("", SEQUENCE(COLUMNS(r)),
LAMBDA(a,b, HSTACK(a, LET(nr, INDEX(r,,b), sr, SORTBY(nr,ROW(nr),-1),
FILTER(sr, sr<>0))))), , 1), ""))
The formula can be further shortened by using TRIMRANGE (Edited on 5-Nov-24)
=LET(r, A2:C12, IFERROR(DROP(REDUCE("", SEQUENCE(COLUMNS(r)),
LAMBDA(a,b, HSTACK(a, LET(nr, TRIMRANGE(INDEX(r,,b)),
SORTBY(nr,ROW(nr),-1))))), , 1), ""))
The Excel file related to this tips can be downloaded from Tips & Tricks 198 – Reverse Multiple Ranges