Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Hyperlinks keep changing | Excel Discussion (Misc queries) | |||
Opening Word Document with Macros and not hyperlinks. | Excel Discussion (Misc queries) | |||
How do I prevent Hyperlinks from changing when saved? | Excel Discussion (Misc queries) | |||
Help: Excel hyperlinks changing... | Excel Discussion (Misc queries) | |||
Changing Hyperlinks? | Excel Discussion (Misc queries) |