hyperlink creation problem

A

Aaron

I'm new and I'm experiencing a few problems. Here is the code:

Sub makelink()
Dim Cell As Range
For Each Cell In Intersect(Selection, ActiveSheet.UsedRange)
If Cell <> "" Then
Dim sLinkAddress As String
sLinkAddress = "http://www.google.com/search?&q=" & Cell.Value
ActiveSheet.Hyperlinks.Add Anchor:=Selection,
Address:=sLinkAddress
End If
Next
End Sub

Problem 1 is that if I select multiple cells, the Cell.Value of the
last cell is used for all of them.
Problem 2 is that if Cell.Value contains a space, it breaks with an
error 400. (maybe the code should convert spaces to plus sign)
Problem 3 is that i need Cell.Value in quotes and adding & Chr(34)
before and after Cell.Value doesnt work.

I know about the hyperlink function but I want a macro so I can store
the search string and call it easily.

Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top