Get the Unstack Data Practice Workbook
Follow along with the same stacked list of apps, sales and profit and turn it into a clean three-column table with the replacement trick.
If you have ever tried to take a column of data in Excel like the following…

and transform it into something like this…

Many different solutions exist for just such a transformation. Some of those solutions include:
- writing a macro using VBA
- developing a Power Query script
- creating an array formula with Ctrl+Shift+Enter
- writing advanced formulas using functions like INDEX , COUNTA, ROWS, and COLUMNS
- purchasing third-party add-ins that are programmed for just such a transformation
This post shows you what we call the laziest way to unstack data. Don’t let the word put you off. It may also be the fastest.
Step 1: Set Up the Headings
In our sample file, we will establish the following headings in cells C5 through E5.

Step 2: Create the Reference Formulas
Now create cell references in cells C6 through E6 that create a structure that represents the way you wish the data looked.

Step 3: Use the LG Replacement Trick
Replace the equal signs in cells C6 through E6 with the letters lg, so =A4 becomes lgA4. Excel now sees text instead of a formula, so the references can’t shift when you drag them. You can use any letters, as long as they don’t appear anywhere else in the cells you’ll select later.

Step 4: Create the Pattern References
We need to discover the pattern at which App names appear in the original stack of data. We can see that there is a new App name every third row, just as there is a new Sale value and a new Profit value every third row.

Using our “LG” replacement trick, create a second row of cell references in cells C7 through E7 that are offset by three rows each.

Step 5: Create the Full List of References
Now that Excel has a pattern to work with, select all the reference cells (C6:E7). Drag the fill handle down. The original list runs to row 87, so go a few rows further to leave room for new data.

Notice how Excel has recognized the row reference pattern in each column and continued the reference.

Step 6: Turn the LG References Into Formulas
Select all the cells that contain “LG” references and perform the following Find/Replace operation (Ctrl+H):
- Find what: lg
- Replace with: = (equal sign)
- Replace All

Close the Find and Replace dialog box. Because you selected the reference cells first, Replace All only changes those cells. Want more Replace tricks? See how to find and replace in Excel.
Step 7: Check the Unstacked List

Notice that we have zeroes in the last few rows of the new list. These will automatically update when new items are added to the original list.
If you wish not to see the zeroes, consider applying the following custom number format to the list.
Press Ctrl+1 to open Format Cells, go to Number > Custom, and enter this in the Type box:
#,##0;-#,##0;
A custom number format has up to four parts, separated by semicolons: positive numbers, negative numbers, zeros and text. Leave the zero part empty and zeros show as blank cells. The cells still contain 0.

This trick works when every record takes up the same number of rows. If some records have extra or missing rows, you need a method that checks for conditions, like Power Query or a more advanced formula.
Bonus Step: Add New Data
Because we included additional rows of cell references, if we add a new entry to the bottom of our original stacked list in Column A…

…the new data appears at the bottom of the unstacked list automatically.

Formula Alternative: INDEX for Any Excel Version
If you would rather create a formula, so as not to rely on the “lazy” method, the following formula will produce the desired result:
=INDEX($A$4:$A$87,ROWS($H$6:H6)+(COUNTA($H$5:$J$5)-1)*(ROWS($H$6:H6)-1)+COLUMNS($H$5:H5)-1)Let’s break this formula down.
$A$4:$A$87 is the original list of items in column A.
ROWS($H$6:H6) will count the rows in the defined range. The range expands by locking the first reference and leaving the second reference relative. When the formula is repeated in the descending rows, the row count will increment (1, then 2, then 3, etc…).
COUNTA($H$5:$J$5) will return the number of non-empty cells in the range H5:J5; in this case, 3.
COLUMNS($H$5:H5) will count the columns in the defined range. The range expands by locking the first reference and leaving the second reference relative. When the formula is repeated in the adjacent columns, the column count will increment (1, then 2, then 3).
Using the first instance of the formula in cell H6 to retrieve the first App, the initial evaluations appear as follows:
=INDEX($A$4:$A$87,1+(3-1)*(1-1)+1-1)Which reduces to…
=INDEX($A$4:$A$87,1+(2)*(0)+0)Further reducing to…
=INDEX($A$4:$A$87,1)This returns the first item in the list, cell A4 (the app WenCaL).
If we look at this for the formula on the same row but for the Sales, we see the following logic:
=INDEX($A$4:$A$87,1+(3-1)*(1-1)+2-1)Which reduces to…
=INDEX($A$4:$A$87,1+(2)*(0)+1)Further reducing to…
=INDEX($A$4:$A$87,2)This will return the item in the second cell of the list; in this case, cell A5 (the sale value 14432).
The formula requires a fair amount of analysis, but to summarize…
ROWS($H$6:H6)+(COUNTA($H$5:$J$5)-1)*(ROWS($H$6:H6)-1) calculates where the next app sits in the original list.
COLUMNS($H$5:H5)-1 will add 0, 1, or 2 to the previous calculation. This offsets the position to allow for the return of the associated sale or profit value.
Using the Evaluate Formula tool located on the Formulas tab, Formula Auditing group will aid greatly in dissecting the logic in a step-by-step fashion.

Microsoft 365 and Excel 2024: Unstack With WRAPROWS
If you have Microsoft 365, Excel 2024 or Excel for the web, one function does the whole job. Enter this in cell C6:
=WRAPROWS(TOCOL(A4:A200,1),3,"")TOCOL with 1 skips the empty cells below your data. WRAPROWS then wraps the list into rows of 3: app, sales and profit. The last argument fills any incomplete row with empty text instead of #N/A.
The result spills into as many rows as it needs. Add new data below the list and it shows up on its own, as long as it stays inside A4:A200.
Additional Resources
Additional functions that can aid in the transformation of data can be found in the following videos:
Download the Unstack Practice Workbook
Get the Free Workbook
Practice the replacement trick on the same data as the tutorial.
Frequently Asked Questions
How do I unstack data from one column into multiple columns in Excel?
Enter the first two records as text references, like lgA4 and lgA7, and drag them down so Excel continues the pattern. Then use Find and Replace to change lg into an equal sign. The text turns into live formulas that pull each value into the right column.
Why does dragging the formula not pick up the right cells?
A relative reference moves one row for every row you drag, but stacked data repeats every few rows. Typing the references as text lets the fill handle copy the step of 3 rows instead. Replace turns them back into formulas afterwards.
Can I use something other than lg in the replacement trick?
Yes. Any letters work, as long as they do not appear anywhere else in the cells you select before Replace All. Your own initials are a safe choice.
How do I hide the zeros at the bottom of the unstacked list?
Select the list, press Ctrl+1 and choose Custom. Enter #,##0;-#,##0; as the format. The third part, for zeros, is empty, so zeros show as blank cells while the formulas stay in place.
Is there a formula to unstack data in Excel?
In Microsoft 365, Excel 2024 and Excel for the web, use =WRAPROWS(TOCOL(A4:A200,1),3,""). In older versions, use an INDEX formula with ROWS and COLUMNS to calculate the position of each value.
Does the unstacked list update when the source data changes?
Yes. Every cell is a formula linked to the original column, so changed values update straight away. New records show up too, as long as you dragged the references far enough down.
Leila Gharani
Founder of XelPlus and ten-time Microsoft MVP. Leila helps over 500,000 professionals master Excel, Power BI, and data automation through practical, real-world training.








