我需要我的代码来自动更改我新创建的超链接名称的字体,并更改它的其他字体属性,因此我需要我的代码来检测何时向工作表添加新的超链接。
"Worksheet_Change“和"Worksheet_FollowHyperlink”也帮不上忙。
更新:以下是我的代码:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim WB As Workbook
Dim WS As Worksheet
Dim TA As ListObject
Dim TA_DateCol As ListColumn
Set WB = ThisWorkbook
Set WS = WB.Sheets(1)
Set TA = WS.ListObjects(1)
If Not Intersect(Target, TA.Range) Is Nothing Then
'This is the part which I want my code to detect if a new hyperlink
'is added but nothing happens my guess is it's because 'Target' type
'in this event handler is a 'Range' not a 'Hyperlink'
End If
End Sub如有任何帮助和建议,我们将不胜感激。The Picture of my code so far
发布于 2021-10-23 10:42:39
将超链接添加到范围不会触发worksheet_change事件。
因此,它不能通过代码检测到这一点。
解决方案是根据您的要求更新工作簿的超链接样式。
有相当多的教程解释了如何做到这一点,例如https://support.microsoft.com/en-us/office/change-the-font-format-for-hyperlinks-672c2905-ad3e-40be-b281-811e68386243
https://stackoverflow.com/questions/69685812
复制相似问题