Hyperlinks help using a cell reference

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
723
Office Version
  1. 2016
Platform
  1. Windows
My code that is giving me trouble is -
VBA Code:
Range("AA5").Hyperlinks.Add Anchor:=Range("AA5"), Address:="https://webaddress.com/?query=" & G5, TextToDisplay:=G5

I'm getting Run-time error 5: Invalid procedure call or argument.

Essentially, what I'm trying to accomplish is to change all cells in column G to a hyperlink. If I could get the above to work, I was going to simply copy and paste the formula down, copy cells in AA and paste them back into G.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Why aren't you using "Option Explicit" before your macro ? it would've been of great help. By the way, what's that G5 that you have in your code ? maybe it's a variable ?
 
Upvote 0
Why aren't you using "Option Explicit" before your macro ? it would've been of great help. By the way, what's that G5 that you have in your code ? maybe it's a variable ?
I’m not using any variables.

G5 is a cell reference
 
Upvote 0
So it's a range and as such it must be treated.
 
Upvote 0
Have you tried (note the added ".Value"):
VBA Code:
[AA5].Hyperlinks.Add Anchor:=[AA5], Address:="https://webaddress.com/?query=" & [G5], TextToDisplay:=[G5].Value
 
Upvote 0
I figured it out

VBA Code:
ActiveSheet.Range("AA5") = "=HYPERLINK(""https://webaddress.com/?query=""&G5,G5)"
 
Upvote 0
Solution
Well, my suggestion was there 4 minutes before you figured it out(y).
 
Upvote 0

Forum statistics

Threads
1,216,116
Messages
6,128,929
Members
449,479
Latest member
nana abanyin

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