View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Aaron[_17_] Aaron[_17_] is offline
external usenet poster
 
Posts: 6
Default hyperlink creation problem

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!