Text to Columns Macro

FinancialAnalystKid

Well-known Member
Joined
Oct 14, 2004
Messages
779
I have a spreadsheet with text and an url in the same cell. Some have an url and some don't. I need to create a new column with the url and delete it from the original cell so I can have 2 cells.

Any help would be greately appreciated!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Does the URL always start with http?
 
Upvote 0
Assuming yes as the answer to my previous question, try...

Code:
Sub splitit()

    With Columns(1)
        .Replace "http:", "§", xlPart
        .TextToColumns OtherChar:="§"
        .Offset(, 1).Replace "//", "http://"
    End With

End Sub
 
Upvote 0
Yes. It contains "http"

I need to highlight the cells say from a2:a200 and run the macro. Is that possible? I tried the attached code and it didn't work. It replaced http with §.

Which gave me an idea. To do a FIND REPLACE http with §http
Then Text to Columns on §

:) Which takes steps but if a Macro won't do, your code gave me that idea! Thanks

If you do have a code that would be great!
 
Upvote 0
On my keyboard it's the same button as the 6. But any unique character in the column is fine... :)
 
Upvote 0
Here you go:

Code:
Sub splitit()

    With Selection
        .Replace "http", "§http", xlPart
        .TextToColumns other:=True, OtherChar:="§"
    End With

End Sub

Only the selection will be done.
 
Upvote 0

Forum statistics

Threads
1,215,329
Messages
6,124,302
Members
449,150
Latest member
NyDarR

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