Reputation: 83
The macro below updates Column A with a hyperlink function.
How do I run this after a data refresh on my query/datasource is clicked?
I tried writing a change condition on my worksheet.
Sub InsertHyperlinkFormulaInCell()
currentRow = 2
While Cells(currentRow, 2) <> "" 'check whether Column B is empty, stop if it is
ActiveWorkbook.Worksheets("Query").Cells(currentRow, 1) = "=HYPERLINK(CONCAT(X" & currentRow & ",B" &
currentRow & "),W" & currentRow & ")"
currentRow = currentRow + 1
Wend
End Sub
Upvotes: 0
Views: 748
Reputation: 166
Instead of manually refreshing your query, do it from the macro and then continue with your code.
Sub InsertHyperlinkFormulaInCell()
Query.QueryTable.Refresh
'rest of your code here
End Sub
Upvotes: 2