Solved

excel hyperlink function within vba

Posted on 2010-09-20
8
807 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now