Solved

excel hyperlink function within vba

Posted on 2010-09-20
8
811 Views
Last Modified: 2012-05-10
I am using the following VBA expression but the interpreter complains that its invalid:
Worksheets("sheet1").Range("J13").Formula = "=HYPERLINK(""http://www.google.com"" | ""GOOGLE"")"

I am simply trying to create a hyperlink inside a cell. I know the excel function =HYPERLINK("http://www.google.ca"|"GOTO www.google.ca")
is correct, why does it not work in VBA?

I am using Excel 2010.
0
Comment
Question by:OTNAdmin
8 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 33719546
Please trt like this:

Worksheets("sheet1").Range("J13").Formula = "HYPERLINK("http://www.google.com";"GOOGLE")"

jppinto
0
 
LVL 6

Expert Comment

by:KnutsonBM
ID: 33719576
Try This:


Worksheets("sheet1").Range("J13").Select
ActiveCell.FormulaR1C1 = _
        "=HYPERLINK(""http://www.google.ca"",""GOTO www.google.ca"")"

-Brandon
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 33719582
Parameters to Excel functions should be seperated by commas...
Worksheets("sheet1").Range("J13").Formula = "=HYPERLINK(""http://www.google.com"", ""GOOGLE"")"
 
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 6

Accepted Solution

by:
KnutsonBM earned 500 total points
ID: 33719602


This one has the wording you wanted:


Worksheets("sheet1").Range("J13").Select
ActiveCell.FormulaR1C1 = _
        "=HYPERLINK(""http://www.google.com"",""Google"")"

-Brandon
0
 
LVL 33

Expert Comment

by:jppinto
ID: 33719649
The correct way to do it, instead of using the .Formula is to use .Hyperlinks, like this:

Worksheets("Sheet1").Range("B3").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= "http://www.google.com/", TextToDisplay:="GOOGLE"

jppinto
0
 
LVL 33

Expert Comment

by:jppinto
ID: 33719664
Or even better:

ActiveSheet.Hyperlinks.Add Anchor:=Range("B3"), Address:= "http://www.google.com/", TextToDisplay:="GOOGLE"

jppinto
0
 
LVL 6

Expert Comment

by:KnutsonBM
ID: 33719721
Many different options to choose from................

-brandon
0
 

Author Comment

by:OTNAdmin
ID: 33719831
thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question