Getting a webpage title into Excel

4

I'm attempting to create a cell that will pull in a hyperlink based off of what is filled out in another excel cell. I have the hyperlink portion working, but I'd like to have a better label for the hyperlink than either the ID it is using to get the web page or the entire web address. I thought it would be easiest to try and pull in the web pages title. Is this possible?

Maybe to help out a little bit, I'm currently using this function to pull in the web address

=IF(LEN(Excel Cell Value)>0,HYPERLINK(CONCATENATE("First part of the web address",(Excel Cell Value),"Second part of the web address"),Excel Cell Value),"")

Sam

Posted 2015-06-10T16:04:43.057

Reputation: 41

http://seotoolsforexcel.com/htmltitle/ – STTR – 2015-06-10T16:50:27.153

I would prefer to just use base excel since I don't want to require every person that wants to use the spreedsheet to have to download an add on – Sam – 2015-06-10T17:01:21.933

Answers

3

=IF(LEN(Excel Cell Value)>0,HYPERLINK(CONCATENATE("First part of the web address",(Excel Cell Value),"Second part of the web address"),Excel Cell Value),"")

I don't understand this. Let me try to break it down -

If(Len(cell value)>0) - if the cell isn't empty, do TRUE
TRUE - Hyperlink(Concatenate(first, (cell value), second), (cell value)
FALSE - ""

Now let's see how hyperlink works

Hyperlink(link location, friendly name)

For you this is

link location = concatenate(first, value, second)
friendly name = value

You are assigning the friendly name to be the cell value. So, unless you have something like -

A1 = Google
A2 = Hyperlink(Concatenate("https://www.",A1,".com",A1))

A2 = Google

This won't work. The only thing you'll be able to do is use VBA to go out to the page and gather information, or use something like -

A1 = Google
A2 = Searching Website
A3 = Hyperlink(Concatenate("https://www.",A1,".com",A2))

A3 = Searching Website


To get the title via VBA -

Sub gettitle()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate "http://superuser.com/"
While ie.busy
 DoEvents
Wend

Dim title As String
title = ie.document.title

MsgBox (title)
End Sub

Okay, to make a function return the hyperlink with the title, you'll need a User Defined Function (UDF) -

Function GetTitle(site As Range) As String
Dim title As String
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate site

While ie.busy
 DoEvents
Wend
title = ie.document.title
ie.Quit
GetTitle = title
End Function

This will go to the webpage target and return the title. So now, say you have a webpage in cell A1 - now you need to call your function for the title -

A2 = GetTitle(A1)
A3 = Hyperlink(A1,A2)

Raystafarian

Posted 2015-06-10T16:04:43.057

Reputation: 20 384