简体   繁体   English

Excel VBA 将单元格内容更新为可点击的超链接

[英]Excel VBA Updating cell contents to be clickable hyperlink

I have a register that has an edit sheet.我有一个有编辑表的寄存器。 The user selects the record they want to update and the code updates the report (Sheet "EditEx") with data from another sheet.用户选择他们想要更新的记录,代码使用另一个工作表中的数据更新报告(工作表“EditEx”)。 the issue is there are a couple of links to sharepoint/folders that are a also recalled.问题是有几个指向共享点/文件夹的链接也被召回。 The sheet updates correctly (displays the full url in the required cell - "H21") however it is not a clickable hyperlink.工作表正确更新(在所需单元格中显示完整 url -“H21”),但它不是可点击的超链接。 I just can't get it to work.我只是无法让它工作。

Here is the end of my code, can anyone help?这是我的代码的结尾,有人可以帮忙吗? Thanks.谢谢。

'   Refresh and unhide all rows
    ActiveWorkbook.RefreshAll
    Sheets("EditEx").Select
    ActiveWindow.SmallScroll Down:=-120
    Rows("29:160").Select
    Selection.EntireRow.Hidden = False
    Rows("32:56").Select
    Rows("32:56").EntireRow.AutoFit
    Rows("76:105").Select
    Rows("76:105").EntireRow.AutoFit
    Rows("125:154").Select
    Rows("125:154").EntireRow.AutoFit
' ISSUE IS HERE
    Range("H21").Hyperlinks.Add Anchor:=Selection, Address:=Selection

'   select first input cell
    Range("C6:D6").Select

    MsgBox ("Record Retrieved. Make your changes and ensure you click 'Save Changes' to update the Master Registers")

End Sub

Never use selection从不使用选择

ActiveSheet.Hyperlinks.Add Anchor:=Range("H21"), _
Address:=Range("H21").Value, _
TextToDisplay:=Range("H21").Value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM