Solved

excel vba assistance - row to list of item

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

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