converting csv text to rows instead of columns

krisso

Active Member
Joined
Sep 16, 2005
Messages
291
Is there a way when importing data from a csv file using the delemiter ; to seperate the data to get excel to put it into rows instead of columns?

The data I am trying to import will exceed the number of columns

Thanks

Chris
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Stormseed

Banned
Joined
Sep 18, 2006
Messages
3,274
Hi Chris,

AFAIK, Excel does not provide the option to convert "text to rows". Nevertheless you can still break up your data using "text to columns" into 256 columns (if you are using Excel 2003 and below), transpose as values, again into 256 columns and so on.

Besides, you can use this formula in order to move your text (assuming the csv text is in A1) into consecutive rows, copied down:

=MID(A$1,ROW(),1)

Hope this helps you :)
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
try
Code:
Sub test()
Dim fn As String, delim As String, temp As String, x
Dim i As Long, ii As Long, a() As String
fn = "c:\test.csv"    '<- file path
delim = ";"
temp = CreateObject("Scripting.FileSytemObject").OpenTextFile(fn).ReadAll
x = Split(temp, vbCrLf)
ReDim a(1 To 10000, 1 To UBound(x) + 1)
For i = 0 To UBound(x)
    y = Split(x(i), delim) 
    For ii = 0 To UBound(y) : a(ii + 1, i + 1) = y(ii) : Next
Next
ThisWorkbook.Sheets(1).Range("a1").Resize(10000, UBound(a,2)).Value = a
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,813
Messages
5,855,785
Members
431,763
Latest member
AlexisChch

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