Solved

excel vba assistance - row to list of item

Posted on 2014-02-26
3
336 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel VBA inserting a formula 12 39
EXCEL String-handling question ... 7 55
Copy one row (from Word) into one cell 14 50
Vlookup (Microsoft Excel Programming) 5 29
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

752 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