Solved

# Returning a parsed list with a slight twist

Posted on 2014-04-25
Medium Priority
127 Views
I have a sheet that can contain items number combined onto one line with the items separated with a "/" or "&" and the various options of the item number

Ex:
PKCANKIT5B/S               5/16      500/400
WXCB8B & 8G               5/15      200/e

The desired results are shown in the column below:
ITEM                       ETA            QTY             NOTES
PKCANKIT5B      5/16            500/400
PKCANKIT5S      5/16            500/400

WXCB8B               5/15      200/e
WXCB8G               5/15      200/e

I need a macro that would do the separating, then append the results to the worksheet, and then delete the original "source" rows

These troubling items are intersperse between other good data (usually about 150 items) with between -15 troubling items

Thanks
Bruj
sampleBOList.xlsm
0
Question by:Bruj
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 36

Accepted Solution

Kimputer earned 2000 total points
ID: 40023828
Using your sample file, this should work:

``````Sub test()

Application.ScreenUpdating = False
Dim currentws As Worksheet
Dim firstvalue
Dim splitvalue

Set currentws = ActiveSheet
rowscount = currentws.UsedRange.Rows.Count

For i = 2 To rowscount
If (InStr(currentws.Cells(i, 1).Value, "/") > 0) Or (InStr(currentws.Cells(i, 1).Value, "&") > 0) Then
firstvalue = Replace(currentws.Cells(i, 1).Value, " ", "")
If InStr(currentws.Cells(i, 1).Value, "/") > 0 Then
splitvalue = Split(firstvalue, "/")
Else
splitvalue = Split(firstvalue, "&")
End If
counter = 1
For Each Value In splitvalue
currentws.Rows(i + counter).Insert
If counter = 1 Then
currentws.Cells(i + counter, 1).Value = splitvalue(0)
For j = 2 To 4 Step 1
currentws.Cells(i + counter, j).Value = currentws.Cells(i, j).Value
Next
Else
currentws.Cells(i + counter, 1).Value = Left(splitvalue(0), Len(splitvalue(0)) - Len(Value)) & Value
For j = 2 To 4 Step 1
currentws.Cells(i + counter, j).Value = currentws.Cells(i, j).Value
Next
End If
rowscount = rowscount + 1
counter = counter + 1
Next
currentws.Rows(i).Delete
End If
Next

Application.ScreenUpdating = True

End Sub
``````
0

Author Closing Comment

ID: 40032160
Works like a champ!

Thanks!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
###### Suggested Courses
Course of the Month12 days, 10 hours left to enroll