Hi,
I am trying to split rows in an Excel spreadsheet. My spreadsheet currently looks like this:
Procedure Description Category Price Modifier1 Modifier2
001234 Plastic bag V $12 TC890 TC990
001235 Paper box V $15 TB003
001236 Tin can J $20 TC999 13556
I would like to use the splitrow() and convert the spreadsheet into:
Procedure Modifiers Description Category Price
001234 TC890 Plastic bag V $12
001234 TC990 Plastic bag V $12
001235 TB003 Paper box V $15
001236 TC999 Tin can J $20
001236 13556 Tin can J $20
The current macro is posted below and it's not working:
Private Sub SplitRows()
Dim oRange As Range, lRow As Long, lCol As Long, oOut As Worksheet, lOut As Long
Dim sValue As String, sGeneral(5) As String, sCode As String
sGeneral(0) = oRange.Cells(lRow, 1).Value
sGeneral(1) = oRange.Cells(lRow, 2).Value
sGeneral(2) = oRange.Cells(lRow, 3).Value
sGeneral(3) = oRange.Cells(lRow, 4).Value
sGeneral(4) = oRange.Cells(lRow, 5).Value
sGeneral(5) = oRange.Cells(lRow, 6).Value
For i = 0 To 5
Set oRange = Application.ActiveSheet.UsedRange
Set oOut = Application.ActiveWorkbook.Worksheets.Add
For lRow = 1 To oRange.Rows.Count
i = oRange.Cells(lRow, 1).Value
If Len(i) <> 0 Then
For lCol = 7 To oRange.Columns.Count
sValue = oRange.Cells(lRow, lCol).Value
If Len(sValue) <> 0 Then
lOut = lOut + 1
oOut.Cells(lOut, 1).Value = i
oOut.Cells(lOut, 2).Value = sValue
End If
Next lCol
End If
Next lRow
Set oRange = Nothing
Set oOut = Nothing
Next
End Sub
Please help,
egghi
I am trying to split rows in an Excel spreadsheet. My spreadsheet currently looks like this:
Procedure Description Category Price Modifier1 Modifier2
001234 Plastic bag V $12 TC890 TC990
001235 Paper box V $15 TB003
001236 Tin can J $20 TC999 13556
I would like to use the splitrow() and convert the spreadsheet into:
Procedure Modifiers Description Category Price
001234 TC890 Plastic bag V $12
001234 TC990 Plastic bag V $12
001235 TB003 Paper box V $15
001236 TC999 Tin can J $20
001236 13556 Tin can J $20
The current macro is posted below and it's not working:
Private Sub SplitRows()
Dim oRange As Range, lRow As Long, lCol As Long, oOut As Worksheet, lOut As Long
Dim sValue As String, sGeneral(5) As String, sCode As String
sGeneral(0) = oRange.Cells(lRow, 1).Value
sGeneral(1) = oRange.Cells(lRow, 2).Value
sGeneral(2) = oRange.Cells(lRow, 3).Value
sGeneral(3) = oRange.Cells(lRow, 4).Value
sGeneral(4) = oRange.Cells(lRow, 5).Value
sGeneral(5) = oRange.Cells(lRow, 6).Value
For i = 0 To 5
Set oRange = Application.ActiveSheet.UsedRange
Set oOut = Application.ActiveWorkbook.Worksheets.Add
For lRow = 1 To oRange.Rows.Count
i = oRange.Cells(lRow, 1).Value
If Len(i) <> 0 Then
For lCol = 7 To oRange.Columns.Count
sValue = oRange.Cells(lRow, lCol).Value
If Len(sValue) <> 0 Then
lOut = lOut + 1
oOut.Cells(lOut, 1).Value = i
oOut.Cells(lOut, 2).Value = sValue
End If
Next lCol
End If
Next lRow
Set oRange = Nothing
Set oOut = Nothing
Next
End Sub
Please help,
egghi