HomeGoogle DocsSpreadsheetWRAPROWS Function in Google Sheets

WRAPROWS Function in Google Sheets

Published on

This tutorial explains how to use the WRAPROWS function in Google Sheets. A similar function is already available in Excel, so some of you might be acquainted with it.

Google introduced a slew of new functions in early 2023, and WRAPROWS is among them, mostly falling under the “Array” category.

What is the purpose of the WRAPROWS function in Google Sheets?

We use the text wrapping (Format > Wrapping > Wrap) command to wrap text within a cell.

However, prior to the introduction of WRAPROWS, there was no specific command or function to wrap a provided row or column of values, necessitating reliance on workarounds.

Related: How to Move Each Set of Rows to Columns in Google Sheets

This is where the WRAPROWS and WRAPCOLS functions prove beneficial. How do these two functions differ?

The former function wraps the provided row or column of cells by rows, whereas the latter does so by columns.

Note:

The function is already featured in the Google Docs help center article here.

If the formula in this tutorial returns a #NAME?, it indicates that the WRAPROWS function has not been made available in your Sheets as of now. Please await the completion of the rollout.

Syntax and Arguments

Syntax: WRAPROWS(range, wrap_count, [pad_with])

Arguments:

range: The range to wrap (a single row or column).

wrap_count: A number representing the maximum number of cells for each row in the output.

If wrap_count isn’t a whole number (e.g., 4.8), the function will round it down to the nearest whole number (4 here).

pad_with: An optional argument in the WRAPROWS function.

If you omit this argument, the function will fill the extra cell(s) with #N/A. For example, if there are seven elements and the wrap_count is 4, the formula will return #N/A in the eighth cell.

Examples of the Use of the WRAPROWS Function in Google Sheets

It’s not too difficult to understand the WRAPROWS function in Google Sheets. Here are a few examples.

Considering there are ten elements in the vertical range A2:A11, let’s wrap it by rows using the WRAPROWS function in Google Sheets.

Transforming a Column into Rows with the WRAPROWS Function in Google Sheets

1. Maximum 5 Numbers Per Each Row:

=WRAPROWS(A2:A11, 5)

2. Maximum 6 Numbers Per Each Row:

=WRAPROWS(A2:A11, 6)

The formula returns two #N/A errors since the total elements in the range are 10, not 12.

3. Replacing #N/A Errors in the WRAPROWS Function:

=WRAPROWS(A2:A11, 6, "x")

4. Matching Total Elements in the Range and Wrap Count:

=WRAPROWS(A2:A11, 10)

The formula will return the same range.

What happens when we have a horizontal range?

The following screenshot is self-explanatory.

Transforming a Row into Rows with the WRAPROWS Function in Google Sheets

WRAPROWS Function and Unstacking of Data (Real-life Use)

In a previous tutorial, we explored the process of unstacking data in Google Sheets.

Typically, we work with stacked data due to the exemplary ease it provides for data manipulation.

However, unstacked data is generally more reader-friendly.

For basic unstacking, the WRAPROWS function in Google Sheets comes in handy. Here’s an example:

Let’s assume you have a category column in A and a value column in B. You can unstack this data if each category contains the same number of rows.

Here is one approach to unstack such data in Google Sheets:

Unstacking Data (Basic Level) in Google Sheets with the WRAPROWS Function

Here, each category contains 4 rows. So the wrap_count in the WRAPROWS formula will be 4.

In cell E3:

=WRAPROWS(B2:B13, 4)

In cell D3 (Supporting UNIQUE Formula):

=UNIQUE(A2:A13)

Now, for the formula in D8:

The above two formulas return a table with a horizontal layout where headers appear in the first column of the table.

To easily transpose the orientation, we need to stack the results of the two formulas horizontally and then transpose it.

Here is the formula for achieving this:

=TRANSPOSE(HSTACK(UNIQUE(A2:A13), WRAPROWS(B2:B13, 4)))
Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Convert Month Name to Days in Google Sheets

We can utilize the EOMONTH, MONTH, DATE, and DAY functions in Google Sheets to...

Creating Custom Descending Sequence Lists in Excel

You can utilize functions like ROW or SEQUENCE in Excel to create a custom...

SUMIFS with XLOOKUP in Excel and Google Sheets

SUMIFS and SUMIF are infamous for producing an "argument must be a range" error...

Counting XLOOKUP Results with COUNTIFS in Excel and Google Sheets

We can use COUNTIF or COUNTIFS alongside an XLOOKUP formula to conditionally count the...

More like this

Convert Month Name to Days in Google Sheets

We can utilize the EOMONTH, MONTH, DATE, and DAY functions in Google Sheets to...

Appointment Schedule Template in Google Sheets

An appointment schedule template in Google Sheets can assist you in efficiently managing your...

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

2 COMMENTS

  1. Dear Prashanth,

    Thank you very much for your blog, which is a great inspiration and an excellent source for finding answers regarding the creative and effective use of Google Sheet functions.

    Regarding this article, especially the last section about using WRAPROWS to unstack:

    I am a little confused about the screenshot.

    With UNIQUE of columns A, we would determine the number of categories, i.e., the number of columns in the resulting table.

    At the same time, the number of elements per category is different. It seems like the wrapping creates an offset of 1 per row (3 vs. 4).

    Have a great day!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.