Skip to content

Fix WRAPROWS / WRAPCOLS #NUM! or #REF! in Google Sheets (wrap count 0 / overwrite)

Updated

WRAPROWS takes a vector and writes it left to right, starting a new row every wrap_count cells. WRAPCOLS writes top to bottom, starting a new column every wrap_count cells. #NUM! means wrap_count is not a positive length — 0, a negative, or a value that rounds to 0. #REF! means the wrapped array would overwrite a cell that already has a value. Leftover cells in the last row pad with #N/A unless you pass pad_with.

This page is wrap count and wrap overwrite. It is not TOCOL / TOROW (flatten first, ignore blanks vs errors). It is not SORT / UNIQUE spill. It is not SEQUENCE spill. Keep the Google Sheets UI in English.

  1. Open a blank spreadsheet. In A1 type codes. A2 N12. A3 E7. A4 W4. A5 S9. A6 C2. Five dock codes in a column.

Wrap count 0. In C1 type wrap0. In C2 enter =WRAPROWS(A2:A6,0). The cell shows #NUM!. There is no row of length zero. wrap_count must be a positive whole number (non-integers round down). Leave C2 broken.

C2 selected. Formula bar shows =WRAPROWS(A2:A6,0). C2 is #NUM!. Tooltip: Function WRAPROWS parameter 2 value is 0. It should be greater than 0. A2:A6 is N12, E7, W4, S9, C2.

A wrap that works. In C5 type wrap2. Leave C6:D8 empty. In C6 enter =WRAPROWS(A2:A6,2). The formula spills two columns: N12 / E7, then W4 / S9, then C2 / #N/A. Five codes, width 2, last cell padded. That block is the control.

Blocked wrap spill. In F1 type blocked. In G2 type keep. Leave F2 empty. In F2 enter =WRAPROWS(A2:A6,2). The cell shows #REF!. The tooltip is Array result was not expanded because it would overwrite data in ‘G2’. Width 2 needs F2 and G2. Leave F2 broken.

F2 selected. Formula bar shows =WRAPROWS(A2:A6,2). F2 is #REF!. Tooltip: Array result was not expanded because it would overwrite data in 'G2'. G2 is keep. C6:D8 is the working wrap.

WRAPCOLS is the other axis. In I1 type cols. Leave I2:K3 empty. In I2 enter =WRAPCOLS(A2:A6,2). Two rows, then a new column: N12 / E7 down the first column, W4 / S9 in the next, C2 / #N/A in the third. Same five codes, different layout.

Count that rounds to zero. In C10 enter =WRAPROWS(A2:A6,0.9). 0.9 rounds down to 0. #NUM! again. Leave C10 broken.

Leave C6 as the working wrap. Leave C2 and F2 as the two errors.

  • wrap_count is a width (or height for WRAPCOLS), not a row index and not “how many leftover cells.” 0 is not “do not wrap.” It is an illegal length. Negative is the same #NUM!.
  • A fractional count is truncated toward zero before the wrap. 2.9 becomes 2 and works. 0.9 becomes 0 and #NUM!.
  • The result is an array. Two-wide wrap of five cells needs three rows and two columns. One occupied cell in that rectangle is #REF! for the whole formula.
  • Default pad is #N/A, not blank. That is not a lookup miss. See what #N/A means for the token only.
  • A 2-D block is still read as a vector, then wrapped. Flatten with TOCOL first if you need column-wise order. See TOCOL / TOROW.

This is not CHOOSECOLS past the range. See CHOOSEROWS / CHOOSECOLS. wrap_count is a chunk size, not an index. This is not a deleted name. See after you delete. F2 still shows WRAPROWS(A2:A6,2).

Leave C2, C10, and F2 broken.

Pass a positive wrap count. Keep C6: =WRAPROWS(A2:A6,2). For a single row of five, =WRAPROWS(A2:A6,5) (no pad). For a column of five, =WRAPCOLS(A2:A6,5) or just leave the source column.

C6 selected. Formula bar shows =WRAPROWS(A2:A6,2). Spill is N12/E7, W4/S9, C2/#N/A with no error triangle on C6. C2 is still #NUM!. F2 is still #REF!.

Replace pad #N/A when a blank should print. In C12 enter =WRAPROWS(A2:A6,2,""). The last cell is empty instead of #N/A. Use IFNA only if you wrapped first and now want to blank pads without changing pad_with. Prefer pad_with. See IFERROR vs IFNA.

Clear G2 or move F2 so the two-column wrap can spill. Do not wrap F2 in IFERROR. You still have no grid.

If #NUM!, the count rounded to 0 or is negative. If #REF! and the formula still says WRAPROWS / WRAPCOLS, look one cell right (rows) or one cell down (cols). If the extra corner is #N/A after a successful spill, that is pad, not a miss.

Two errors, one function family.

#NUM! is the argument. C2 never tried to write a grid. Fix 0, 0.9, or -1 first.

#REF! is occupancy. Count 2 is legal. F2 needs a clear rectangle. Same overwrite family as SORT / UNIQUE spill. TOCOL makes a vector; WRAPROWS turns a vector into a table. Do not pass wrap_count 0 expecting flatten.