
別の Excel セルに入力された内容に基づいてハイパーリンクを取得するセルを作成しようとしています。ハイパーリンク部分は機能していますが、Web ページを取得するために使用している ID や Web アドレス全体よりも、ハイパーリンクに適したラベルを付けたいと思っています。Web ページのタイトルを取得するのが最も簡単だと思いました。これは可能ですか?
少しでもお役に立てればと思い、現在この機能を使ってウェブアドレスを取得しています
=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),"")
答え1
=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),"")
理解できません。説明してみます。
If(Len(cell value)>0) - if the cell isn't empty, do TRUE
TRUE - Hyperlink(Concatenate(first, (cell value), second), (cell value)
FALSE - ""
ハイパーリンクがどのように機能するかを見てみましょう
Hyperlink(link location, friendly name)
あなたにとってこれは
link location = concatenate(first, value, second)
friendly name = value
セルの値にフレンドリ名を割り当てています。したがって、次のようなものがない限り、
A1 = Google
A2 = Hyperlink(Concatenate("https://www.",A1,".com",A1))
A2 =グーグル
これは機能しません。VBA を使用してページにアクセスし、情報を収集するか、次のようなものを使用することしかできません。
A1 = Google
A2 = Searching Website
A3 = Hyperlink(Concatenate("https://www.",A1,".com",A2))
A3 =ウェブサイトを検索
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
さて、関数にタイトル付きのハイパーリンクを返すようにするには、ユーザー定義関数(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
これはウェブページターゲットに行き、タイトルを返します。セルにウェブページがあるとしますA1
。タイトルの関数を呼び出す必要があります。
A2 = GetTitle(A1)
A3 = Hyperlink(A1,A2)