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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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 :)
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

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