Macro for txt list to xls table

MollieR

New Member
Joined
Mar 13, 2009
Messages
5
I need a way to take a list of people's info (name, address, etc) and put it into sorted columns. The step I really need help with is getting Excel to go from a single column of listed info to multiple columns, each containing a single contact.

The number of rows per contact varies, but there is always a single empty row between contacts. Any thoughts?

Thanks!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
Try this code:

Code:
Sub test()
Dim myRange As Range, lastRow As Long, writeRow As Long, writeCol As Long
writeRow = 1
writeCol = 1
With Sheets("Raw Data")
    lastRow = .Cells(Rows.Count, 1).End(xlUp).Row
    
    For Each myRange In .Range("A1:A" & lastRow)
    
        If myRange = "" Then
        
            writeRow = writeRow + 1
            writeCol = 1
        
        Else
        
            Sheets("Output").Cells(writeRow, writeCol) = myRange.Value
            writeCol = writeCol + 1
        
        End If
        
    Next myRange
    
End With
End Sub

Takes the data from sheet named Raw Data and writes to one called Output.

Dom
 
Upvote 0

Forum statistics

Threads
1,191,218
Messages
5,985,325
Members
439,958
Latest member
qb0000

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
Top