Solved

excel hyperlink function within vba

Posted on 2010-09-20
8
810 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

776 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