Solved

Returning a parsed list with a slight twist

Posted on 2014-04-25
2
122 Views
Last Modified: 2014-04-30
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       
PKSDKRA/B/C                             400/e      Will Advise
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       
                  
PKSDKRA                            400/e      Will Advise
PKSDKRB                            400/e      Will Advise
PKSDKRC                            400/e      Will Advise
                  
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
Comment
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
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

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

Sub test()

Application.ScreenUpdating = False
Dim currentws As Worksheet
Dim AddedRows
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

Open in new window

0
 

Author Closing Comment

by:Bruj
ID: 40032160
Works like a champ!

Thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question