Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default Changing Hyperlinks in Macros

For a project at work, I need to add a new sheet that contains information
for a new distributor. The problem is, in the macro I have, when I try to
create a hyperlink, it will hyperlink to the same sheet every time. If I
needed to have the macro hyperlink to a new sheet, how can I do this?

I'd REALLY appreciate any help you might have...
  #2   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Changing Hyperlinks in Macros

show the revelent part of the macro and we can probably tell you how to
change it. There are multiple ways to do what you want but any given method
may not work with your set up.
we will need how you name and set up the path to the hyperlink target.

"Elise148" wrote:

For a project at work, I need to add a new sheet that contains information
for a new distributor. The problem is, in the macro I have, when I try to
create a hyperlink, it will hyperlink to the same sheet every time. If I
needed to have the macro hyperlink to a new sheet, how can I do this?

I'd REALLY appreciate any help you might have...

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default Changing Hyperlinks in Macros

This is what I have...when I run it it says that the sheet cannot be found...


Sub Hyperlinking()
' Hyperlinking Macro

Sheets("Individual Distrib.").Select
Sheets("Individual Distrib.").Copy After:=Sheets(11)
Range("A1").Select
Sheets("Individual Distrib. (2)").Name = InputBox("Enter the number of
the new distributor.")

Sheets("Individual Distrib.").Select
Range("A11").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:=InputBox("Enter the number of the new distributor.")

End Sub




"bj" wrote:

show the revelent part of the macro and we can probably tell you how to
change it. There are multiple ways to do what you want but any given method
may not work with your set up.
we will need how you name and set up the path to the hyperlink target.

"Elise148" wrote:

For a project at work, I need to add a new sheet that contains information
for a new distributor. The problem is, in the macro I have, when I try to
create a hyperlink, it will hyperlink to the same sheet every time. If I
needed to have the macro hyperlink to a new sheet, how can I do this?

I'd REALLY appreciate any help you might have...

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Changing Hyperlinks in Macros

The following is a typical way to generate and follow a hyperlink in VBA to a
location in the workbook:

Sub go_hyper()
Dim s As String
s = "file:///C:\Documents and Settings\ravenswood\Desktop\Book2.xls#Sheet2!B9"
ActiveWorkbook.FollowHyperlink (s)
End Sub

as you point out the sheet is always Sheet2. To hyperlink to the latest or
newest sheet, let's assume that the latest sheet is the last sheet. We get
the name of that sheet and hyperlink to that one:

Sub go_hyper_latest()
Dim s As String
n = Sheets.Count
s2 = Sheets(n).Name & "!B9"
MsgBox (s2)
s = "file:///C:\Documents and Settings\ravenswood\Desktop\Book2.xls#" & s2
ActiveWorkbook.FollowHyperlink (s)
End Sub
--
Gary''s Student - gsnu200732


"Elise148" wrote:

For a project at work, I need to add a new sheet that contains information
for a new distributor. The problem is, in the macro I have, when I try to
create a hyperlink, it will hyperlink to the same sheet every time. If I
needed to have the macro hyperlink to a new sheet, how can I do this?

I'd REALLY appreciate any help you might have...

  #5   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Changing Hyperlinks in Macros

I think what your macro does the hyperlink address is ""

try
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=InputBox("Enter the
number of the new distributor.")
or set a variable = the new distributor name earlier in the macro and use
that variable


"Elise148" wrote:

This is what I have...when I run it it says that the sheet cannot be found...


Sub Hyperlinking()
' Hyperlinking Macro

Sheets("Individual Distrib.").Select
Sheets("Individual Distrib.").Copy After:=Sheets(11)
Range("A1").Select
Sheets("Individual Distrib. (2)").Name = InputBox("Enter the number of
the new distributor.")

Sheets("Individual Distrib.").Select
Range("A11").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:=InputBox("Enter the number of the new distributor.")

End Sub




"bj" wrote:

show the revelent part of the macro and we can probably tell you how to
change it. There are multiple ways to do what you want but any given method
may not work with your set up.
we will need how you name and set up the path to the hyperlink target.

"Elise148" wrote:

For a project at work, I need to add a new sheet that contains information
for a new distributor. The problem is, in the macro I have, when I try to
create a hyperlink, it will hyperlink to the same sheet every time. If I
needed to have the macro hyperlink to a new sheet, how can I do this?

I'd REALLY appreciate any help you might have...



  #6   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Changing Hyperlinks in Macros

the subaddress, if I understand it, goes to a spot in a sheet, not to the
sheet itself

"Elise148" wrote:

This is what I have...when I run it it says that the sheet cannot be found...


Sub Hyperlinking()
' Hyperlinking Macro

Sheets("Individual Distrib.").Select
Sheets("Individual Distrib.").Copy After:=Sheets(11)
Range("A1").Select
Sheets("Individual Distrib. (2)").Name = InputBox("Enter the number of
the new distributor.")

Sheets("Individual Distrib.").Select
Range("A11").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:=InputBox("Enter the number of the new distributor.")

End Sub




"bj" wrote:

show the revelent part of the macro and we can probably tell you how to
change it. There are multiple ways to do what you want but any given method
may not work with your set up.
we will need how you name and set up the path to the hyperlink target.

"Elise148" wrote:

For a project at work, I need to add a new sheet that contains information
for a new distributor. The problem is, in the macro I have, when I try to
create a hyperlink, it will hyperlink to the same sheet every time. If I
needed to have the macro hyperlink to a new sheet, how can I do this?

I'd REALLY appreciate any help you might have...

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
Hyperlinks keep changing Cadwan Excel Discussion (Misc queries) 0 May 11th 07 07:32 PM
Opening Word Document with Macros and not hyperlinks. Thew21 Excel Discussion (Misc queries) 2 April 4th 07 07:43 PM
How do I prevent Hyperlinks from changing when saved? Doug Excel Discussion (Misc queries) 0 March 13th 06 01:15 AM
Help: Excel hyperlinks changing... StuB Excel Discussion (Misc queries) 2 November 30th 05 03:04 PM
Changing Hyperlinks? Madvikefan Excel Discussion (Misc queries) 2 April 14th 05 04:52 PM


All times are GMT +1. The time now is 11:55 PM.

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"