kambing_tempur,
With your raw data in worksheet Sheet1. You can change the raw data worksheet name in the macro.
With your raw data sorted/grouped by the text in column A.
Here is a macro solution, and, Function, for you to consider, based on your flat text display, and, it will adjust to the number of raw data rows, and, columns needed for the results.
Sample raw data, and, results:
Excel 2007 |
---|
|
---|
| A | B | C | D | E | F | G |
---|
1 | 1A | | 1A | 1B | 1C | | |
---|
2 | 1B | | 2A | 2B | 2C | | |
---|
3 | 1C | | 3A | 3B | 3C | | |
---|
4 | 2A | | 4A | 4B | 4C | 4D | |
---|
5 | 2B | | | | | | |
---|
6 | 2C | | | | | | |
---|
7 | 3A | | | | | | |
---|
8 | 3B | | | | | | |
---|
9 | 3C | | | | | | |
---|
10 | 4A | | | | | | |
---|
11 | 4B | | | | | | |
---|
12 | 4C | | | | | | |
---|
13 | 4D | | | | | | |
---|
14 | | | | | | | |
---|
|
---|
Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).
1. Copy the below code, and, Function
2. Open your NEW workbook
3. Press the keys
ALT +
F11 to open the Visual Basic Editor
4. Press the keys
ALT +
I to activate the Insert menu
5. Press
M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys
ALT +
Q to exit the Editor, and return to Excel
8. To run the macro from Excel press
ALT +
F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.
Code:
Sub ReorgData()
' hiker95, 11/25/2016, ME977400
Dim r As Long, lr As Long, n As Long, nr As Long
Application.ScreenUpdating = False
With Sheets("Sheet1") '<-- you can change the sheet name here
lr = .Cells(Rows.Count, 1).End(xlUp).Row
.Range("B1").Formula = "=GetDigits(A1)"
.Range("B1").Copy .Range("B2:B" & lr)
nr = 0
For r = 1 To lr
nr = nr + 1
n = Application.CountIf(.Columns(2), .Cells(r, 2).Value)
.Cells(nr, 3).Resize(, n).Value = Application.Transpose(.Range("A" & r & ":A" & r + n - 1))
.Cells(r, 2).Resize(n).ClearContents
r = r + n - 1
Next r
.UsedRange.Columns.AutoFit
End With
Application.ScreenUpdating = True
End Sub
Function GetDigits(ByVal Text As String) As String
' Rick Rothstein, MrExcel MVP, 08/18/2011, ME572628
' http://www.mrexcel.com/forum/excel-questions/572628-extract-numbers-string.html
Dim X As Long
For X = 1 To Len(Text)
If Not Mid(Text, X, 1) Like "#" Then Mid(Text, X) = " "
Next
GetDigits = Replace(Text, " ", "")
End Function
Before you use the macro, and, Function, with
Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension
.xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
Then run the
ReorgData macro.