Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Need to add hyperlink using VBA code

I am working in Excel 2007.
Given a row with a company name in the A cell, and a company category in the
D cell, I need to create a worksheet with the name of the company category
(D), copy the contents of a template worksheet to the new worksheet, and
create a hyperlink from the company name (A) to the new worksheet.
I've got everything working except the last bit. I have already spent at
least 2 hours looking at bulletins on this subject, but nothing that I try
works. Here is the hyperlink code as it now stands:
vCell = "A" & Trim(Str(pRow))
WS.Activate
WS.Hyperlinks.Add Anchor:=WS.Range(vCell), Address:="'" & pName & "'!A1"
pRow is the cell on the original worksheet - in this case, vCell = A17
WS is the original worksheet, not the one just created
pName is the name of the new worksheet, so I am setting Address to 'New
Company!A1' I have also tried it with just the name (no !A17).
I have also tried the hyperlinks like with Cells(pRow,1) instead of
Range(vCell). It had no effect.
This code does not bomb, it just doesn't do anything. At the end of each
test, the new worksheet exist just as I want it to be, but I cannot
automatically jump to it by clicking on the company name.
What am I doing wrong?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Need to add hyperlink using VBA code

Try this:

WS.Hyperlinks.Add Anchor:=WS.Range(vCell), Address:="", SubAddress:="'" &
pName & "'!A1"

Ο χρήστης "Bev Kaufman" *γγραψε:

I am working in Excel 2007.
Given a row with a company name in the A cell, and a company category in the
D cell, I need to create a worksheet with the name of the company category
(D), copy the contents of a template worksheet to the new worksheet, and
create a hyperlink from the company name (A) to the new worksheet.
I've got everything working except the last bit. I have already spent at
least 2 hours looking at bulletins on this subject, but nothing that I try
works. Here is the hyperlink code as it now stands:
vCell = "A" & Trim(Str(pRow))
WS.Activate
WS.Hyperlinks.Add Anchor:=WS.Range(vCell), Address:="'" & pName & "'!A1"
pRow is the cell on the original worksheet - in this case, vCell = A17
WS is the original worksheet, not the one just created
pName is the name of the new worksheet, so I am setting Address to 'New
Company!A1' I have also tried it with just the name (no !A17).
I have also tried the hyperlinks like with Cells(pRow,1) instead of
Range(vCell). It had no effect.
This code does not bomb, it just doesn't do anything. At the end of each
test, the new worksheet exist just as I want it to be, but I cannot
automatically jump to it by clicking on the company name.
What am I doing wrong?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Need to add hyperlink using VBA code

That was one of my earlier efforts. It doesn't create the hyperlink. What
it does do is place New Category'!A1 in A17 of the new worksheet.


"John_John" wrote:

Try this:

WS.Hyperlinks.Add Anchor:=WS.Range(vCell), Address:="", SubAddress:="'" &
pName & "'!A1"

Ο χρήστης "Bev Kaufman" *γγραψε:

I am working in Excel 2007.
Given a row with a company name in the A cell, and a company category in the
D cell, I need to create a worksheet with the name of the company category
(D), copy the contents of a template worksheet to the new worksheet, and
create a hyperlink from the company name (A) to the new worksheet.
I've got everything working except the last bit. I have already spent at
least 2 hours looking at bulletins on this subject, but nothing that I try
works. Here is the hyperlink code as it now stands:
vCell = "A" & Trim(Str(pRow))
WS.Activate
WS.Hyperlinks.Add Anchor:=WS.Range(vCell), Address:="'" & pName & "'!A1"
pRow is the cell on the original worksheet - in this case, vCell = A17
WS is the original worksheet, not the one just created
pName is the name of the new worksheet, so I am setting Address to 'New
Company!A1' I have also tried it with just the name (no !A17).
I have also tried the hyperlinks like with Cells(pRow,1) instead of
Range(vCell). It had no effect.
This code does not bomb, it just doesn't do anything. At the end of each
test, the new worksheet exist just as I want it to be, but I cannot
automatically jump to it by clicking on the company name.
What am I doing wrong?

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 run code Martin Excel Discussion (Misc queries) 7 October 22nd 08 06:01 PM
Hyperlink to code Daniel Bonallack Excel Discussion (Misc queries) 3 October 6th 08 10:23 PM
Hyperlink Code oberon.black[_103_] Excel Programming 2 September 29th 05 10:45 PM
Using Hyperlink via code mick Excel Programming 0 March 3rd 05 09:57 PM
Using Hyperlink via code Mick[_8_] Excel Programming 0 March 3rd 05 06:36 PM


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

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

About Us

"It's about Microsoft Excel"