0

I've setup in several places in my file the following sheet formulas:

=HYPERLINK("#restoreDefaultForRange(rngI)","Restore defaults")

The # allows me to run the macro restoreDefaultForRange() from the current workbook. Inside the Macro, I have the code below that allows me to speed up the runtime:

 Application.EnableEvents = False
 Application.ScreenUpdating = False
 Application.Calculation = xlCalculationManual
 Application.DisplayAlerts = False

If I run restoreDefaultForRange() from VBA, everithing works fine, and the events and calculation are turned off. If I run the same macro by clicking on the Hyperlink, the code above is ignored and the macro runs super slow because Events and calculation remain ON. It's exactly the same macro, and does the same actions.

Can anyone help explain this behaviour? Is there is a way I can correct it?

braX
  • 11,506
  • 5
  • 20
  • 33
Dumitru Daniel
  • 571
  • 4
  • 19
  • I think code called from a hyperlink like this falls under the same restrictions as code running in a UDF. You can instead use a regular hyperlink and the `Worksheet_FollowHyperlink` event which isn't restricted in the same way. – Tim Williams May 23 '22 at 22:54
  • @TimWilliams do you know where I can find mode documentation about this? I try to google this, but I honestly did not know what to search for. – Dumitru Daniel May 24 '22 at 06:50
  • About what specifically? You won't find much about limitations of functions called from hyperlinks - that's a pretty niche use case and there's not much available on it. Some discussion here: https://stackoverflow.com/questions/28728600/in-excel-can-i-use-a-hyperlink-to-run-vba-macro – Tim Williams May 24 '22 at 16:28

0 Answers0