AFLIP

AFLIP(Array,[Direction])
Array
Required. Array to flip order.
[Direction]
Optional. 0 or ignored☛ flip data horizontally; 1☛ flip vertically; 2☛ both

AFLIP returns an array in reverse horizontal order, vertical order, or both.

schardt679

Board Regular
Joined
Mar 27, 2021
Messages
58
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
AFLIP returns an array in reverse horizontal order, vertical order, or both.

Thanks to GeertD's FLIPARRAYH & FLIPARRAYV functions and Chandoo's How to REVERSE data in Excel with Formulas (3 tricks) for the inspiration.
Calls IFBLANK & CELLCOUNT.
Other functions on minisheet: AFORMULATEXT.

Screen Tip/ Comment: =AFLIP(Array☛ range to flip order, [Direction]☛ 0/❎=horizontally✅; 1=vertically; 2=both) ⁂[]=optional; ✅=default; ❎=omit

Excel Formula:
=LAMBDA(Array,[Direction],
      LET(Arr, IFBLANK(Array,  ""),          Dir, IFERROR(--(Direction), 3),
             DirScan, AND(Dir<>{2,1,0}),          DirMSG, "Direction=0,1,2",
             RowCt, CELLCOUNT(Arr, 1),          RowSeq, SORT(SEQUENCE(RowCt),, IF(Dir=0, 1,  -1)),
             ColCt, CELLCOUNT(Arr, 2),          ColSeq, SORT(SEQUENCE(, ColCt),, IF(Dir=1, 1,  -1), 1),
             Result, INDEX(Arr, RowSeq, ColSeq),          Return, IF(DirScan, DirMSG,  Result),
             Return
      )
  )
LAMBDA Examples.xlsx
ABCDEFGHIJK
1AFLIP
2
3Original DataDirectionResult
4ProductSalesDateDateSalesProduct
5Pepper Deseeder1903/22/2103/22/2119Pepper Deseeder
6Knife Set403/22/2103/22/214Knife Set
7Cutting Board703/22/2103/22/217Cutting Board
8Pepper Deseeder2603/23/2103/23/2126Pepper Deseeder
9Knife Set2803/23/2103/23/2128Knife Set
10Cutting Board1603/23/2103/23/2116Cutting Board
11Pepper Deseeder03/24/2103/24/21Pepper Deseeder
12
13Array is flipped horizontally
14Formula in cell H4☛ =AFLIP(B4:D11, F4)
15
16
17
18Original DataDirectionResult
19ProductSalesDate1Pepper Deseeder03/24/21
20Pepper Deseeder1903/22/21Cutting Board1603/23/21
21Knife Set403/22/21Knife Set2803/23/21
22Cutting Board703/22/21Pepper Deseeder2603/23/21
23Pepper Deseeder2603/23/21Cutting Board703/22/21
24Knife Set2803/23/21Knife Set403/22/21
25Cutting Board1603/23/21Pepper Deseeder1903/22/21
26Pepper Deseeder03/24/21ProductSalesDate
27
28Array is flipped vertically
29Formula in cell H19☛ =AFLIP(B19:D26, F19)
30
31
32Original DataDirectionResult
33ProductSalesDate203/24/21Pepper Deseeder
34Pepper Deseeder1903/22/2103/23/2116Cutting Board
35Knife Set403/22/2103/23/2128Knife Set
36Cutting Board703/22/2103/23/2126Pepper Deseeder
37Pepper Deseeder2603/23/2103/22/217Cutting Board
38Knife Set2803/23/2103/22/214Knife Set
39Cutting Board1603/23/2103/22/2119Pepper Deseeder
40Pepper Deseeder03/24/21DateSalesProduct
41
42Array is flipped both horizontally and vertically
43Formula in cell H33☛ =AFLIP(B33:D40, F33)
44
AFLIP
Cell Formulas
RangeFormula
H4:J11,H33:J40,H19:J26H4=AFLIP(B4:D11, F4)
B14,B43,B29B14=AFORMULATEXT(H4)
Dynamic array formulas.
 
Upvote 0
Now we have MAKEARRAY, you can make it simpler
This formula flips horizontally without requiring other helper lambdas (a vertical flip option can be added easily)

Excel Formula:
=LAMBDA(a,LET(c,COUNTA(INDEX(a,1,)),r,COUNTA(INDEX(a,,1)),MAKEARRAY(r,c,LAMBDA(rr,cc,INDEX(a,rr,c+1-cc)))))

(The COUNTA functions count rows and columns)
 

Forum statistics

Threads
1,224,829
Messages
6,181,222
Members
453,024
Latest member
Wingit77

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