- #Microsoft excel transpose cells how to#
- #Microsoft excel transpose cells code#
- #Microsoft excel transpose cells free#
In the Combine Rows Based on Column dialog box, please do the following operations: Then click Kutools > Merge & Split > Advanced Combine Rows, see screenshot:ģ. (If you want to keep the original data, please copy and paste the data to another location firstly.)Ģ.
Select the data range that you want to use.
#Microsoft excel transpose cells free#
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.Īfter installing Kutools for Excel, please do as follows:ġ. If you have Kutools for Excel, combining the Advanced Combine Rows and Split Cells utilities, you can quickly finish this task without any formulas or code. Click OK button, and the data in column B has been transposed based on unique values in column A, see screenshot: And then click OK button, another prompt box will pop out to remind you to select a cell to put the result, see screenshot:Ħ. Then press F5 key to run this code, and a prompt box will pop out to remind you select the data range that you want to use, see screenshot:Ĥ. XOutRg.Resize(1, xCount + 1).PasteSpecial Paste:=xlPasteFormatsģ. XOutRg.Offset(i, 1).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True XRg.Range("B2:B" & xLRow).SpecialCells(xlCellTypeVisible).Copy If xVRg.Count > xCount Then xCount = xVRg.Count Set xVRg = xRg.Range("B2:B" & xLRow).SpecialCells(xlCellTypeVisible) XRg.AutoFilter Field:=1, Criteria1:=xCrit XCol.Add xRg.Cells(i, 1).Value, xRg.Cells(i, 1).Value Set xOutRg = Application.InputBox("please select output range(specify one cell):", "Kutools for Excel", xTxt,, ,, , 8) MsgBox "the used range is only one area with two columns ",, "Kutools for Excel" Set xRg = Application.InputBox("please select data range(only two columns):", "Kutools for Excel", xTxt,, ,, , 8)
VBA code: Transpose cells in one column based on unique values in another column: Sub transposeunique()
#Microsoft excel transpose cells code#
Click Insert > Module, and paste the following code in the Module Window. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.Ģ. May be the formulas are complex for you to understand, here, you can run the following VBA code to get the desired result you need.ġ. And then continue dragging the fill handle down to the range of cells to get the transposed data as following screenshot shown: Then drag the fill handle to right of the cells that you want to list the transposed data until displays 0, see screenshot:ĥ. Note: In above formula: B2:B16 is the column data that you want to transpose, A2:A16 is the column that you want to transpose the values based on, and D2 contains the unique value that you have extracted in Step 1.Ĥ. And then go on entering this formula into cell E2: =IFERROR(INDEX($B$2:$B$16, MATCH(0, COUNTIF($D2:D2,$B$2:$B$16)+IF($A$2:$A$16$D2, 1, 0), 0)), 0), and remember to press Shift + Ctrl + Enter keys to get the result, see screenshot: Then drag the fill handle down to the cells to extract all the unique values, see screenshot:ģ. Note: In the above formula, A2:A16 is the column that you want to list the unique values from, and D1 is the cell above this formula cell.Ģ.
Enter this array formula: =INDEX($A$2:$A$16, MATCH(0, COUNTIF($D$1:$D1, $A$2:$A$16), 0)) into a blank cell, D2, for example, and press Shift + Ctrl + Enter keys together to get the correct result, see screenshot: With the following array formulas, you can extract the unique values and transpose their corresponding data into horizontal rows, please do as follows:ġ. Transpose cells in one column based on unique values with Kutools for Excel Transpose cells in one column based on unique values with VBA code Transpose cells in one column based on unique values with formulas Do you have any good ideas to solve this problem in Excel?
Supposing, you have a range of data which contains two columns, now, you want to transpose cells in one column to horizontal rows based on unique values in another column to get the following result.
#Microsoft excel transpose cells how to#
How to transpose cells in one column based on unique values in another column?