Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-27-2015, 03:50 AM
saurabhlotankar saurabhlotankar is offline Text to Rows Windows XP Text to Rows Office 2010 32bit
Novice
Text to Rows
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default Text to Rows

Hi Everyone,



Please find attached excel sheet. In column A there are few values. some of the cells have multiple values. I want to split such values.
But challenge is I dont want to split value and paste in next column(the way we do in Text to Column). I what i want is if there are 3 vales in cell A1(Split by alt+entre) then code should add 2 more rows below that and paste 2 vales in those two rows.

If its confusing, please refer to my sheet. In cell A1, there are 3 values Alex, Smith and peter. What I want is it should i deally add 2 more rows below A1 and pase smith and peter respectively in it.

Thanks
Attached Files
File Type: xlsx Book2.xlsx (8.6 KB, 10 views)
Reply With Quote
  #2  
Old 05-27-2015, 05:49 AM
NoSparks NoSparks is offline Text to Rows Windows 7 64bit Text to Rows Office 2010 32bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Give this a try
Code:
Sub NamesToRows()
    Dim lr As Long
    Dim i As Long
    Dim arr As Variant
    
With Sheets("Sheet1")
    lr = .Cells(Rows.Count, 1).End(xlUp).Row
    For i = lr To 1 Step -1
        With Cells(i, 1)
            arr = Split(.Value, Chr(10))
            If UBound(arr) > 0 Then
                .Offset(1, 0).EntireRow.Resize(UBound(arr)).Insert
                .Resize(UBound(arr) + 1) = Application.Transpose(arr)
            End If
        End With
    Next i
End With
End Sub
Reply With Quote
  #3  
Old 05-27-2015, 06:09 AM
saurabhlotankar saurabhlotankar is offline Text to Rows Windows XP Text to Rows Office 2010 32bit
Novice
Text to Rows
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default

Its working fine dear. Thanks a lot for this. God bless you.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Text to Rows Delete blank rows between the two rows that contain data beginner Excel Programming 5 12-26-2014 12:29 AM
Text to Rows Delete All empty Rows - Print - Undo all Rows deleted Bathroth Word VBA 1 10-01-2014 01:40 PM
Text to Rows Grouping table rows to prevent individual rows from breaking across pages dennist77 Word 1 10-29-2013 11:39 PM
Text to Rows Delete Blank Rows (Cyrillic Text in Spreadsheet ) dozd Excel 1 02-22-2013 03:24 AM
Text to Rows Count rows and add blank rows accordingly Hoochtheseal Word VBA 1 01-29-2013 09:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft