Marcro or formula to extract urls from a bunch of text in a column of cells

dominicp

New Member
Joined
Nov 3, 2009
Messages
15
I have a column of cells over 2000 rows that have a bunch of text in each cell. In the middle of this text in each cell are websites (not hyperlinked). I was wondering if someone wrote a macro or formula to extract URLs located in a bunch of text? I can parse this out but doing some delimiting but that will take longer.
 
Then it will be Columns(7).
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
sorry to be dense about this.

i tried the code and got an error.

my data starts on cell g2 and end in g2800.

Will this code check each cell in the column or do i need to modify?

in the code i did the folowing

Sub fff()
For Each r In Columns(7).SpecialCells(2, 2)
r.Offset(, 1) = "www" & Split(Split([g2], "www")(1))(0)
Next
End Sub


but it seems to only take the URL from cell G2 and put it next to all the cells
 
Upvote 0
My typo w.r.t. that one:

Rich (BB code):
Sub fff()
    For Each r In Columns(1).SpecialCells(2, 2)
        r.Offset(, 1) = "www" & Split(Split(r, "www")(1))(0)
    Next
End Sub
 
Upvote 0
so i put this in and got an error subscript out of range.

i changed the code so that it was column 7..

anything else i need to do?

my Data starts of G2 and ends on G2008.
 
Upvote 0
wait its probably blowing up if it hits a cell that doesn't have a url...

i tried to clean these out but they might exist in my data set.

anyway to have it just skip that cell and go to next
 
Upvote 0
Like this:

Code:
Sub fff()
    For Each r In Columns(7).SpecialCells(2, 2)
        If InStr(r, "www") Then r.Offset(, 1) = "www" & Split(Split(r, "www")(1))(0)
    Next
End Sub

Wigi
 
Upvote 0

Forum statistics

Threads
1,215,148
Messages
6,123,307
Members
449,095
Latest member
Chestertim

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