Solved

excel vba assistance - row to list of item

Posted on 2014-02-26
3
333 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
ID: 39891091
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
ID: 39891099
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
ID: 39891165
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

832 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