Solved

excel vba assistance - row to list of item

Posted on 2014-02-26
3
328 Views
Last Modified: 2014-02-27
Hello All:

I am looking for a macro to split a row of data

Data:

sample|A,B,C
sample2|X,Y,Z

Output

Sample
A
B
C

Sample2
X
Y
Z

thanks
0
Comment
Question by:CalmSoul
3 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
try this from link
http://stackoverflow.com/questions/8560718/split-comma-separated-entries-to-new-rows

I have tried this and works exatly as per you requirment

please finmd attached excel for demo
New-Microsoft-Excel-Worksheet--2.xlsx
0
 
LVL 3

Expert Comment

by:Sreeram
Comment Utility
Try this :

Sub Macro1()
    Dim SplitValue As Variant
        SplitValue = Split(ActiveCell.Value, ",")
            ActiveSheet.Range("B1").Select
          For I = 0 To UBound(SplitValue)
            ActiveCell.Value = SplitValue(I)
            ActiveCell.Offset(1, 0).Select
          Next I
End Sub
0
 
LVL 24

Accepted Solution

by:
Steve earned 500 total points
Comment Utility
The following should do what you require quite quickly.
(This assumes that your data has the "|" seperator for titles and commas for the values as per your question)

Sub mySplit()
Dim r As Range
Dim d, a

Set r = Range("A1:A3")

d = Join(Application.Transpose(r), ",,")
d = Replace(d, "|", ",")
a = split(d, ",")
Range("B1").Resize(UBound(a) + 1) = Application.Transpose(a)

End Sub

Open in new window

See attached example
Example.xlsm
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now