Importing Data Delimited by 2 Spaces

dubvie

New Member
Joined
Jun 6, 2005
Messages
12
I am having a problem importing a text file into excel. The data in the file is delimited by 2 spaces instead of 1. Any ideas on how to quickly Import the file?

I tried doing a find and replace on the 2 spaces, but it is taking FOREVER.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
How are you importing it?

Isn't there an option in the Text Import wizard to 'Treat consecutive delimiters as one'?
 
Upvote 0
I cannot use the consecutive delimiters option b/c of the fact that the delimiter is 2 spaces and some of the data between 2 delimiters (say an address) contains 1 space.

Thanks for the help though... any other ideas?
 
Upvote 0
Import you text file into column A without any parsing and run this macro:

Code:
Sub Test()
    With ActiveSheet.Columns(1)
        .Replace "  ", "@"
        .TextToColumns Destination:=.Cells(1, 1), DataType:=xlDelimited, _
        Tab:=False, Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar:="@"
    End With
End Sub

Use a character other than @ if your text file already contains it.
 
Upvote 0
Thanks Andrew, that worked great!

A friend of mine also pointed me to his website http://www.nandeshwar.info/projects/xlblog/

where he had the following solution:

------------------------------------------------------
Public Sub parse_file()
Application.ScreenUpdating = False
Dim i As Integer, j As Long, k As Long, no_of_rows As Long, storeVal, parsedVal
no_of_rows = Range("A65536").End(xlUp).Row
For i = 1 To no_of_rows
storeVal = Range("A" & i)
parsedVal = Split(storeVal, " ")
j = UBound(parsedVal)
Range(Cells(i, 1), Cells(i, j + 1)) = parsedVal
Next i
Application.ScreenUpdating = True
MsgBox "Done"
End Sub

--------------------------------------------------------------

Your's was much faster however, so I'll use that. Thanks again!
 
Upvote 0

Forum statistics

Threads
1,206,827
Messages
6,075,099
Members
446,121
Latest member
Malikai

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