ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   hyperlink creation problem (https://www.excelbanter.com/excel-programming/432861-hyperlink-creation-problem.html)

Aaron[_17_]

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!

Aaron[_17_]

hyperlink creation problem
 
Update: Solved problem 3


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com