最基本的參數參:Hyperlinks.Add、Hyperlinks 物件
小編最常用的是連結開啟檔案、連結MAIL、連結網站、連結工作表的儲存格
寫給自己看,也作分享
連結開啟檔案:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOURCE_SHEET=ACTIVESHEET.NAME | |
Sheets(SOURCE_SHEET).Range("B" & i).Hyperlinks.Delete | |
Sheets(SOURCE_SHEET).Range("B" & i).Hyperlinks.Add Anchor:=Sheets(SOURCE_SHEET).Range("B" & i), Address:=FILE_PATH, _ | |
TextToDisplay:="'" & Sheets(SOURCE_SHEET).Range("B" & i).Value '"'"是避免數字錯誤。 |
FILE_PATH:是檔案路徑
連結MAIL:參考:Hyperlinks.Add
連結網站:參考:Hyperlinks.Add
連結工作表的儲存格:
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'工作表名稱'!儲存格位置如A1", TextToDisplay:="鉀肥"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sheets("工作表1").Range("a" & i).Hyperlinks.Delete | |
Sheets("工作表1").Range("a" & i).Hyperlinks.Add Anchor:=Sheets("工作表1").Range("a" & i), Address:="", SubAddress:=stock & "!A1", TextToDisplay:=Sheets("工作表1").Range("a" & i).Value '& "'" | |
stock:工作表名稱的變數
沒有留言:
張貼留言