Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default UDF that returns a Hyperlink

Is it possible in Excel 2007 using VBA to create a UDF that returns a
hyperlink?

Ideally I want a hyperlink where the display name is different to the
linked URL.

Any ideas?

TIA

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default UDF that returns a Hyperlink

First, if you mean you want the tooltip to show a different address, then I
don't think that it's possible.

Second, if you meant you want to see something in the cell that isn't the
address of the link, then...

There's an =hyperlink() worksheet function that may do exactly what you want:

=hyperlink("http://www.microsoft.com","Click me!")

Third, If you want to use the Insert|Hyperlink style of hyperlink:

I didn't test this in xl2007, but it seemed to work fine in xl2003:

Option Explicit
Function myHyperLink()

With Application.Caller
.Parent.Hyperlinks.Add Anchor:=.Cells, _
Address:="http://www.microsoft.com"
End With

myHyperLink = "Click me!"
End Function


If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=myHyperLink()

Vlad wrote:

Is it possible in Excel 2007 using VBA to create a UDF that returns a
hyperlink?

Ideally I want a hyperlink where the display name is different to the
linked URL.

Any ideas?

TIA


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default UDF that returns a Hyperlink

What capability do you need that the existing worksheet function:
=HYPERLINK()
does not give you?
--
Gary''s Student - gsnu200909


"Vlad" wrote:

Is it possible in Excel 2007 using VBA to create a UDF that returns a
hyperlink?

Ideally I want a hyperlink where the display name is different to the
linked URL.

Any ideas?

TIA

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default UDF that returns a Hyperlink

Thanks Dave for your suggestions

Gary - I want to use VBA to calculate a URL based on some conditions.
Is it possible to use the hyperlink function in VBA?

Thanks
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default UDF that returns a Hyperlink

You can create a formula using =hyperlink() using VBA.

You can insert a hyperlink (insert|hyperlink) using VBA.

You can use a macro that uses:
Thisworkbook.followhyperlink
and run that macro when you want to.

Vlad wrote:

Thanks Dave for your suggestions

Gary - I want to use VBA to calculate a URL based on some conditions.
Is it possible to use the hyperlink function in VBA?

Thanks


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default UDF that returns a Hyperlink

I want to create a formula using =hyperlink() using VBA - have you any
pointers on that?
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default UDF that returns a Hyperlink

activecell.formula = "=hyperlink(""http://www.microsoft.com"",""Click me"")"

But your question is kind of vague. You can pick up those strings (or even
pieces of those strings) from anything that you can get to using VBA.



Vlad wrote:

I want to create a formula using =hyperlink() using VBA - have you any
pointers on that?


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink to url returns error: cannot open the specified file browniebodrum Excel Discussion (Misc queries) 7 May 18th 23 11:45 AM
Index with mulitple value returns and muliple column returns solar+CSE Excel Worksheet Functions 4 June 12th 09 04:43 PM
Date returns always returns: 00 January 1900 ArcticWolf Excel Worksheet Functions 2 September 11th 08 12:31 PM
Intra-workbook hyperlink: macro/function to return to hyperlink ce marika1981 Excel Discussion (Misc queries) 3 May 6th 05 05:47 AM
reading html when hyperlink address not hyperlink text diplayed Kevin Excel Programming 1 December 4th 03 10:13 PM


All times are GMT +1. The time now is 03:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"