Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Split Cell Into Seperate Rows

I have a table of data that displays Mothers Name in Column A and Children
in a column B

Where one mother has multiple children I have been entering all the children
in a single cell, seperated by using Alt+Enter

How would I seperate the contents of the cells in column B so that each
child occupies an individual row?

Thanks

Andy


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Split Cell Into Seperate Rows

Andy,

Try this (as an example) - names in B1 are placed in cells C
onwards:


HTH

Sub x()
Dim v As Variant

v = Split(Range("b1"), Chr(10))

r = 1
For i = 0 To ubound(v)
Cells(r, i + 3) = v(i)
Next i

End Sub



"Andibevan" wrote:

I have a table of data that displays Mothers Name in Column A and Children
in a column B

Where one mother has multiple children I have been entering all the children
in a single cell, seperated by using Alt+Enter

How would I seperate the contents of the cells in column B so that each
child occupies an individual row?

Thanks

Andy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Split Cell Into Seperate Rows

Hey Toppers - Thanks for the great code - I was stumped.

I have managed to modify it a bit:-

It may be of use to someone else?

Sub Split_Cell_into_Rows()

Dim v As Variant
Dim rngLoc As Range
Dim rngRow As Integer
Dim rngCol As Integer
Dim RowNum As Integer 'Number of rows within source cell
Set rngLoc = Range(ActiveCell.Address) 'Location of cell
rngRow = ActiveCell.Row
rngCol = ActiveCell.Column

v = Split(rngLoc, Chr(10))
RowNum = UBound(v) '+ 1

ActiveCell.Offset(1, 0).Rows("1:" & RowNum).EntireRow.Insert
Shift:=xlDown


For i = 0 To UBound(v)
Cells(i + rngRow, rngCol) = v(i)

Next i
End Sub


"Toppers" wrote in message
...
Andy,

Try this (as an example) - names in B1 are placed in cells C
onwards:


HTH

Sub x()
Dim v As Variant

v = Split(Range("b1"), Chr(10))

r = 1
For i = 0 To ubound(v)
Cells(r, i + 3) = v(i)
Next i

End Sub



"Andibevan" wrote:

I have a table of data that displays Mothers Name in Column A and

Children
in a column B

Where one mother has multiple children I have been entering all the

children
in a single cell, seperated by using Alt+Enter

How would I seperate the contents of the cells in column B so that each
child occupies an individual row?

Thanks

Andy





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
Spliting a cell with multiple entries into seperate rows melmil Excel Discussion (Misc queries) 1 April 7th 09 09:22 PM
split data into seperate worksheets by criteria emma1402 Excel Worksheet Functions 2 July 3rd 08 09:23 PM
How to seperate data in a cell which is split by a comma Eamonn Excel Worksheet Functions 1 March 29th 06 09:30 AM
Seperate/Split celinput peter Excel Worksheet Functions 2 August 6th 05 08:41 AM
Auto-Hiding rows based on cell in seperate worksheet James C[_3_] Excel Programming 2 July 23rd 04 05:16 PM


All times are GMT +1. The time now is 07:52 AM.

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"