Refresh and link VBA codes

paulohp

New Member
Joined
Nov 16, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
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?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top