Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default How seperate text with comma in a cell into seperate rows

I wanted to seperate text with comma in a cell into different row for
example

Before :

Capasitor 3 C123,C124,C125
Diode 2 D110,111
Transistor 3 T101,T102,T103

After

Capasitor 1 C123
Capasitor 1 C124
Capasitor 1 C125
Diode 1 D110
Diode 1 D111
Transistor 1 T101
Transistor 1 T102
Transistor 1 T103

How to create Excel VBA ? Need urgently...pls help guy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default How seperate text with comma in a cell into seperate rows

Hi

With before data in columns A:C and "after" data in columns D:F, try
this.



Sub seperate()
firstRow = 2
LastRow = Range("A" & Rows.Count).End(xlUp).Row
rw = 2
For r = firstRow To LastRow
Comp = Range("A" & r).Value
txt = Split(Range("C" & r).Value, ",")
For c = 0 To UBound(txt)
Range("D" & rw) = Comp
Range("E" & rw) = 1
Range("F" & rw) = txt(c)
rw = rw + 1
Next
Next
End Sub

Hopes this helps.

---
Per

On 8 Maj, 16:57, geniusideas wrote:
I wanted to seperate text with comma in a cell into different row for
example

Before :

Capasitor * * * 3 * * * * C123,C124,C125
Diode * * * * * * 2 * * * * D110,111
Transistor * * * 3 * * * * T101,T102,T103

After

Capasitor * * * *1 * * * * *C123
Capasitor * * * *1 * * * * *C124
Capasitor * * * *1 * * * * *C125
Diode * * * * * * *1 * * * * *D110
Diode * * * * * * *1 * * * * *D111
Transistor * * * *1 * * * * *T101
Transistor * * * *1 * * * * *T102
Transistor * * * *1 * * * * *T103

How to create Excel VBA ? Need urgently...pls help guy


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default How seperate text with comma in a cell into seperate rows

On May 8, 11:24*pm, Per Jessen wrote:
Hi

With before data in columns A:C and "after" data in columns D:F, try
this.

Sub seperate()
firstRow = 2
LastRow = Range("A" & Rows.Count).End(xlUp).Row
rw = 2
For r = firstRow To LastRow
* * Comp = Range("A" & r).Value
* * txt = Split(Range("C" & r).Value, ",")
* * For c = 0 To UBound(txt)
* * * * Range("D" & rw) = Comp
* * * * Range("E" & rw) = 1
* * * * Range("F" & rw) = txt(c)
* * * * rw = rw + 1
* * Next
Next
End Sub

Hopes this helps.

---
Per

On 8 Maj, 16:57, geniusideas wrote:

I wanted to seperate text with comma in a cell into different row for
example


Before :


Capasitor * * * 3 * * * * C123,C124,C125
Diode * * * * * * 2 * * * * D110,111
Transistor * * * 3 * * * * T101,T102,T103


After


Capasitor * * * *1 * * * * *C123
Capasitor * * * *1 * * * * *C124
Capasitor * * * *1 * * * * *C125
Diode * * * * * * *1 * * * * *D110
Diode * * * * * * *1 * * * * *D111
Transistor * * * *1 * * * * *T101
Transistor * * * *1 * * * * *T102
Transistor * * * *1 * * * * *T103


How to create Excel VBA ? Need urgently...pls help guy


Tq for code, it's work. the only thing I need to remove the original
list meaning new list will be in same column.Your vb code create a
list in another column.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How seperate text with comma in a cell into seperate rows

We need a little more information. One, where did you want the expanded data
to go... in another column or did you want it to replace the original data?
Two, what if there were repeated codes from in a row; for example...

Capasitor 3 C123,C124,C124

did you want each C124 in its own row or did you want them summed together
on a single line, like this...

Capasitor 1 C123
Capasitor 2 C124

--
Rick (MVP - Excel)


"geniusideas" wrote in message
...
I wanted to seperate text with comma in a cell into different row for
example

Before :

Capasitor 3 C123,C124,C125
Diode 2 D110,111
Transistor 3 T101,T102,T103

After

Capasitor 1 C123
Capasitor 1 C124
Capasitor 1 C125
Diode 1 D110
Diode 1 D111
Transistor 1 T101
Transistor 1 T102
Transistor 1 T103

How to create Excel VBA ? Need urgently...pls help guy


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
add two cells from seperate work sheets into a cell on seperate wo lar Excel Worksheet Functions 6 April 27th 10 06:54 PM
How do I seperate a full name field out into three seperate columns? Rod Excel Worksheet Functions 3 October 31st 06 08:06 PM
seperate first 2 lines of column in seperate columns in same row Glynnhamer Excel Discussion (Misc queries) 2 October 9th 06 04:23 AM
How to seperate data in a cell which is split by a comma Eamonn Excel Worksheet Functions 1 March 29th 06 09:30 AM
Split Cell Into Seperate Rows Andibevan[_4_] Excel Programming 2 December 20th 05 06:35 PM


All times are GMT +1. The time now is 06:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"