Excel VBA:如何从单元格值自动创建超链接? [英] Excel VBA: How to autocreate hyperlink from cell value?
本文介绍了Excel VBA:如何从单元格值自动创建超链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在列B中,我有票号。例如:76537434
要求:当B列中的任何单元格发生任何更改时,该单元格(目标单元格)将被更改为超链接,以使超链接地址为example.com/id=76537434
单元格值即76537434必须保持不变
解决方案
将此事件处理程序添加到工作表的代码模块中:
Private Sub Worksheet_Change(ByVal Target As Range)
如果Target.Column<> 2然后退出Sub
Target.Hyperlinks.Delete'或Target.ClearHyperlinks以节省格式
Me.Hyperlinks.Add Target,http://example.com/id=& Target.value
End Sub
I have a table called Table1
In Column B, I have the ticket number. e.g: 76537434
Requirement: when any change happens in any cell in column B, that cell (Target cell) to be changed into a hyperlink such that the hyperlink address would be example.com/id=76537434
Cell value i.e. 76537434 must remain the same
解决方案
Add this event handler to your worksheet's code module:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 2 Then Exit Sub
Target.Hyperlinks.Delete ' or Target.ClearHyperlinks to conserve the formatting
Me.Hyperlinks.Add Target, "http://example.com/id=" & Target.value
End Sub
这篇关于Excel VBA:如何从单元格值自动创建超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文