Moving data into separate rows

Bensmeat

New Member
Joined
Mar 8, 2009
Messages
2
Hi

I have a question its quite hard to explain, ive got a spreadsheet with information that has been input on separate lines within a single row using the alt+enter function.

I need to create a macro that takes the information out of the row and places it in separate rows i.e each line within the row needs to go on its own row, i think this needs a picture to explain..

infom.png


Thanks alot for your help!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi there,

Welcome to the forum.

Run the following AltEnterExtract macro on the first cell you want the data to be extracted to (it will work in any column but where the source data resides - i.e. Column A in this case):

Code:
Sub AltEnterExtract()

Dim intChrCnt As Integer
Dim varTemp As Variant

    'Assumes the 'ALT+ENTER' data is in A1 to A[whatever row]. _
    Change if required.
    For Each cell In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
    
        For intChrCnt = 1 To Len(cell.Value)
            If Mid$(cell.Value, intChrCnt, 1) <> Chr(10) Then
                varTemp = varTemp & Mid$(cell.Value, intChrCnt, 1)
            Else
                'Output will be in the Column the cursor was on _
                (activecell) when the macro was executed.
                With ActiveCell
                    .Value = varTemp
                    .Offset(1, 0).Select
                End With
                varTemp = ""
            End If
        Next
        
        If varTemp <> "" Then
            With ActiveCell
                .Value = varTemp
                .Offset(1, 0).Select
            End With
            varTemp = ""
        End If
        
    Next cell
    
End Sub

HTH

Robert
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top