Solved

excel hyperlink function within vba

Posted on 2010-09-20
8
813 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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: 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.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

691 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