≡ ▼
=FLIP(array, [dimension])
=FLIPUD(array)
=FLIPLR(array)
ArgumentDescriptionExample
arrayAn array consisting of numbers or text{1, 2, 3; "A", "B", "C"}
dimension1=Rows (default), 2=Columns1

Download the Template

In the template file, navigate to the Arrays worksheet to see the FLIP, FLIPUD, FLIPLR function in action.

Description

Reversing the order of the the rows or columns of an array can be done using CHOOSEROWS, CHOOSECOLS and the SEQUENCE functions. However, remembering how to do it may take time. FLIP is the more general function because it lets you choose either dimension=1 (same as FLIPUD) or dimension=2 (same as FLIPLR). FLIPLR means "flip left-right." FLIPUD means "flip up-down."

FLIPLR(array) = CHOOSECOLS(array,SEQUENCE(1,COLUMNS(array),COLUMNS(array),-1))
FLIPUD(array) = CHOOSEROWS(array,SEQUENCE(ROWS(array),1,ROWS(array),-1))

If your data is already sorted, then changing the sort direction may be the same thing as FLIP. However, if you specifically do NOT want to sort your data and ONLY want to reverse the order, that is where FLIP is handy.

Lambda Formula

This code for using FLIP, FLIPUD, FLIPLR in Excel is provided under the License as part of the LAMBDA Library, but to use just this function, you may copy the following code directly into your spreadsheet.

Code for AFE Workbook Module (Excel Labs Add-in)

/**
* Reverses the order of the rows, unless it is a single row or 
* dimension=2, then reverses the columns
*/
FLIP = LAMBDA(array,[dimension],
LET(doc,"https://www.vertex42.com/lambda/flip.html",
    dimension,IF(ISOMITTED(dimension),1,dimension),
    rows,ROWS(array),
    cols,COLUMNS(array),
    IF(OR(dimension=2,rows=1),
        CHOOSECOLS(array,SEQUENCE(1,cols,cols,-1)),
        CHOOSEROWS(array,SEQUENCE(rows,1,rows,-1))
    )
));

/**
* Reverses the order of the rows of an array
*/
FLIPUD = LAMBDA(array,
LET(doc,"https://www.vertex42.com/lambda/flip.html",
    rows,ROWS(array),
    CHOOSEROWS(array,SEQUENCE(rows,1,rows,-1))
));

/**
* Reverses the order of the columns of an array
*/
FLIPLR = LAMBDA(array,
LET(doc,"https://www.vertex42.com/lambda/flip.html",
    cols,COLUMNS(array),
    CHOOSECOLS(array,SEQUENCE(1,cols,cols,-1))
));

Named Function for Google Sheets

Name: FLIP
Description: Reverses the order of the rows, unless it is a single row or dimension=2, then reverses the columns
Arguments: array, dimension
Function:

LET(doc,"https://www.vertex42.com/lambda/flip.html",
    dimension,IF(ISBLANK(dimension),1,dimension),
    rows,ROWS(array),
    cols,COLUMNS(array),
    IF(OR(dimension=2,rows=1),
        CHOOSECOLS(array,SEQUENCE(1,cols,cols,-1)),
        CHOOSEROWS(array,SEQUENCE(rows,1,rows,-1))
    )
)
Warning
These functions are not compatible between Excel and Google Sheets. When using these functions, you will not be able to convert the Excel file to Google Sheets or vice versa without problems.

FLIP Examples

Example
Use FLIP, FLIPLR or FLIPUD to reverse the order of rows and columns of the array shown in the image. FLIP, FLIPLR and FLIPUD Example
Test: Copy and Paste the LET function into a cell
=LET(
    array, {"A1","B1","C1"; "A2","B2","C2"; "A3","B3","C3"},
    FLIP(array,1)
)

=LET(
    array, {"A1","B1","C1"; "A2","B2","C2"; "A3","B3","C3"},
    FLIPLR(array)
)

=LET(
    array, {"A1","B1","C1"; "A2","B2","C2"; "A3","B3","C3"},
    FLIPUD(array)
)
Disclaimer: This article is meant for educational purposes only. See the License regarding the LAMBDA code, and the site Terms of Use for the documentation.