Here's the problem:
I have a large spreadsheet filled with data across columns A:J. Each cell in each column contains a single value, EXCEPT columns F:H, which contain delimited data. I need to split these cells into multiple rows so that each row in the spreadsheet is unique and each cell has a single value.
I found the following thread, which got me most of the way: http://www.mrexcel.com/forum/excel-...ting-single-rows-data-into-multiple-rows.html
Specifically, this bit of code:
The problem with this code is that it splits columns one at a time. In my specific case, the columns containing delimited data have it in a specific order. For example, the first item in column F should pair with the first item in column G, which should pair with the first item in column H. Below is example data.
<tbody>
</tbody>
I need the data in the following format:
<tbody>
</tbody>
I have a large spreadsheet filled with data across columns A:J. Each cell in each column contains a single value, EXCEPT columns F:H, which contain delimited data. I need to split these cells into multiple rows so that each row in the spreadsheet is unique and each cell has a single value.
I found the following thread, which got me most of the way: http://www.mrexcel.com/forum/excel-...ting-single-rows-data-into-multiple-rows.html
Specifically, this bit of code:
Code:
Sub RedistributeData() Dim X As Long, LastRow As Long, A As Range, Table As Range, Cell As Range, Data() As String
Const Delimiter As String = ","
Const DelimitedColumn As String = "F"
Const TableColumns As String = "A:J"
Const StartRow As Long = 2
Application.ScreenUpdating = False
LastRow = Columns(TableColumns).Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
For X = LastRow To StartRow Step -1
Data = Split(Cells(X, DelimitedColumn), Delimiter)
If UBound(Data) Then
Intersect(Rows(X + 1), Columns(TableColumns)).Resize(UBound(Data)).Insert xlShiftDown
End If
Cells(X, DelimitedColumn).Resize(UBound(Data) + 1) = WorksheetFunction.Transpose(Data)
Next
LastRow = Cells(Rows.Count, DelimitedColumn).End(xlUp).Row
On Error GoTo NoBlanks
Set Table = Intersect(Columns(TableColumns), Rows(StartRow).Resize(LastRow - StartRow + 1))
On Error GoTo 0
For Each A In Table.SpecialCells(xlBlanks).Areas
A.FormulaR1C1 = "=R[-1]C"
A.Value = A.Value
Next
NoBlanks:
Application.ScreenUpdating = True
End Sub
The problem with this code is that it splits columns one at a time. In my specific case, the columns containing delimited data have it in a specific order. For example, the first item in column F should pair with the first item in column G, which should pair with the first item in column H. Below is example data.
ID | Title | Date | Type | Status | Names | Division | Dept | Lead | Dept |
123 | XXX Vaccine | 7/18/2008 | Other | Active | Oz,Kemp,Brown | Med,Med,Eng | Int Med,Hem Onc,Materials | Kemp | Hem Onc |
124 | DDX5 | 7/21/2008 | Process | Closed | James,Li,Shi,Ge | Med,Med,LSA,Other | Int Med,Int Med,Physics, | James | Int Med |
125 | Nanoemulsion | 8/5/2008 | Therapeutic | Exclusive | Wang,Sun | Med,Med | Allergy,Allergy | Wang | Allergy |
<tbody>
</tbody>
I need the data in the following format:
ID | Title | Date | Type | Status | Names | Division | Dept | Lead | Dept |
123 | XXX Vaccine | 7/18/2008 | Other | Active | Oz | Med | Int Med | Kemp | Hem Onc |
123 | XXX Vaccine | 7/18/2008 | Other | Active | Kemp | Med | Hem Onc | Kemp | Hem Onc |
123 | XXX Vaccine | 7/18/2008 | Other | Active | Brown | Eng | Materials | Kemp | Hem Onc |
124 | DDX5 | 7/21/2008 | Process | Closed | James | Med | Int Med | James | Int Med |
124 | DDX5 | 7/21/2008 | Process | Closed | Li | Med | Int Med | James | Int Med |
124 | DDX5 | 7/21/2008 | Process | Closed | Shi | LSA | Physics | James | Int Med |
124 | DDX5 | 7/21/2008 | Process | Closed | Ge | Other | James | Int Med | |
125 | Nanoemulsion | 8/5/2008 | Therapeutic | Exclusive | Wang | Med | Allergy | Wang | Allergy |
125 | Nanoemulsion | 8/5/2008 | Therapeutic | Exclusive | Sun | Med | Allergy | Wang | Allergy |
<tbody>
</tbody>