Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a huge excel list (20k+ rows) and want to split that one column list into multiple columns. Previously I used the Data|Text-to-Columns Wizard but it appears to have a limitation: I cannot specify after how many "splits" to stop to split. Example data:

type: abds : das
files: asdfs:jgkd

goal is:

|type|abds : das|
|files|asdfs:jgkd|

thanks for your time :)!

share|improve this question

migrated from stackoverflow.com Mar 2 '13 at 10:05

This question came from our site for professional and enthusiast programmers.

5  
How about split all columns and then concatenate 2 & 3 back? –  Maks Gordeev Feb 28 '13 at 22:17

3 Answers 3

up vote 0 down vote accepted

VBA is a great tool for small one off tasks like this.

Assuming data is in column A and is contiguous from A1. If this is not the case, simply adjust the line Set rng = ... to suit your data.

Sub SplitColumn()
    Dim rng As Range
    Dim dat As Variant
    Dim i As Long, j As Long

    Set rng = Range([a1], [a1].End(xlDown)).Resize(, 2)
    dat = rng
    For i = 1 To UBound(dat, 1)
        j = InStr(dat(i, 1), ":")
        If j > 0 Then
            dat(i, 2) = Mid$(dat(i, 1), j + 1)
            dat(i, 1) = Left$(dat(i, 1), j - 1)
        End If
    Next
    rng = dat
End Sub
share|improve this answer

Normally you would write some vbscript to do this task, but if it is a one-column sheet, you could save it as Text (tab-delimited), then open it again. The Excel will ask you what kind of text file is it. Tell it that it is a file with Separators, click Next and tick Other and type a colon in the edit field.

share|improve this answer

You could replace the first colon with a "|" - or some other character that won't appear in your data - using:

=SUBSTITUTE(A1,":","|",1)

Then copy and paste the the results as values and do a Text To Columns on those values.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.