Share via

Refresh and Hyperlink VBA codes

Anonymous
2022-11-17T13:02:28+00:00

Hello,
I don't knowmuch about VBA but searching on the internet I could find some macros that help me do what I need.
I have a power query bringing some emails to my sheet, I need to have the sheet refreshed every minute and the native function in excel does not work when more than one person is editing the sheet.

I foun this code, implemented it and it works very well:

Sub Main()

ActiveWorkbook.RefreshAll

Call Refresh_Macro

End Sub

Private Sub Refresh_Macro()

Application.OnTime Now + TimeSerial(0, 1, 30), "Main"

End Sub

Now I also need to have a collumn that comes from the query with some urls to be clickable hyperlinks and the HYPERLINK function does not work because the urls are longer than 255 characters. Then I found the following code which also works:

Sub HyperAdd()

For Each xCell In Range("i2", Range("i2").End(xlDown))
ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=xCell.Formula, TextToDisplay:="Job"

Next xCell

End Sub

It happens that every time that the query updates I loose the hyperlinks.
What I'm trying to do is to insert the HyperAdd macro inside the loop so everytime that the sheet is updated the refered column will become hyperlinks again.
I have already tried but my VBA knowledge is really limited.

How can I managed to make this work?

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Steve Rindsberg 99,166 Reputation points MVP Volunteer Moderator
    2022-11-17T14:52:10+00:00

    Hello Paolo,

    This seems to be mainly an Excel question. You'll have a better chance of finding answers to it if you post your question in the Excel section of MS Answers also.

    Was this answer helpful?

    0 comments No comments