Sub main()
Dim s As String, t As String
s = "http://www.domain.net/sub1/sub2/etc/page.html"
t = ural(s)
MsgBox (t)
End Sub
Function ural(inpt As String) As String
Dim sep As String
sep = "/"
t = Split(inpt, sep)
ural = t(0) & sep & sep & t(1) & sep & t(2) & sep
End Function
--
Gary''s Student - gsnu200855
"Charlotte E" wrote:
In Excel 2003 VBA, how to quickly extract a base domain from a given URL?
I.e.
http://www.domain.net/sub1/sub2/etc/page.html
would become
http://www.domain.net/
or...
ftp://ftp.server.net/sub1
would become
ftp://ftp.server.net/
or...
www.website.net
would become
http://www.website.net/
and also secure sites
https://www.securesite.net/index.asp
would become
https://www.securesite.net/
and maybe even
ftp.site.net
would become
ftp://ftp.site.net/
TIA,