Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro add Hyperlink formula

A formula that finally works (thanks Dave Ritchie) is
=HYPERLINK("#"&CELL("address",Datasheet!C15),Datas heet!C15). I can copy and
it to other cells and also don't get cannot open specified file error

But how do I automate the creation of the the macro from original cell
contents of
=Datasheet!c15 or =+Datasheet!C15 to above hyperlink formula

Thanks very much.
Charles
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro add Hyperlink formula

Select the range to change and try this macro:

Option Explicit
Sub testme02()
Dim myRng As Range
Dim myCell As Range
Dim myStr As String

Set myRng = Selection
For Each myCell In myRng.Cells
If myCell.HasFormula Then
myStr = Mid(myCell.Formula, 2)
If Left(myStr, 1) = "+" Then
myStr = Mid(myStr, 2)
End If
'=HYPERLINK("#"&CELL("address",Datasheet!C15),Data sheet!C15)
myCell.Formula = "=hyperlink(""#""&cell(""address""," _
& myStr & ")," & myStr & ")"
End If
Next myCell

End Sub


cmarch wrote:

A formula that finally works (thanks Dave Ritchie) is
=HYPERLINK("#"&CELL("address",Datasheet!C15),Datas heet!C15). I can copy and
it to other cells and also don't get cannot open specified file error

But how do I automate the creation of the the macro from original cell
contents of
=Datasheet!c15 or =+Datasheet!C15 to above hyperlink formula

Thanks very much.
Charles


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro add Hyperlink formula

Thanks Dave, I always find your posts work beautifully. One quick question,
why does it have to have Option Explicit?

Thanks

"Dave Peterson" wrote:

Select the range to change and try this macro:

Option Explicit
Sub testme02()
Dim myRng As Range
Dim myCell As Range
Dim myStr As String

Set myRng = Selection
For Each myCell In myRng.Cells
If myCell.HasFormula Then
myStr = Mid(myCell.Formula, 2)
If Left(myStr, 1) = "+" Then
myStr = Mid(myStr, 2)
End If
'=HYPERLINK("#"&CELL("address",Datasheet!C15),Data sheet!C15)
myCell.Formula = "=hyperlink(""#""&cell(""address""," _
& myStr & ")," & myStr & ")"
End If
Next myCell

End Sub


cmarch wrote:

A formula that finally works (thanks Dave Ritchie) is
=HYPERLINK("#"&CELL("address",Datasheet!C15),Datas heet!C15). I can copy and
it to other cells and also don't get cannot open specified file error

But how do I automate the creation of the the macro from original cell
contents of
=Datasheet!c15 or =+Datasheet!C15 to above hyperlink formula

Thanks very much.
Charles


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro add Hyperlink formula

Never mind, found Option Explicit explanation

"cmarch" wrote:

Thanks Dave, I always find your posts work beautifully. One quick question,
why does it have to have Option Explicit?

Thanks

"Dave Peterson" wrote:

Select the range to change and try this macro:

Option Explicit
Sub testme02()
Dim myRng As Range
Dim myCell As Range
Dim myStr As String

Set myRng = Selection
For Each myCell In myRng.Cells
If myCell.HasFormula Then
myStr = Mid(myCell.Formula, 2)
If Left(myStr, 1) = "+" Then
myStr = Mid(myStr, 2)
End If
'=HYPERLINK("#"&CELL("address",Datasheet!C15),Data sheet!C15)
myCell.Formula = "=hyperlink(""#""&cell(""address""," _
& myStr & ")," & myStr & ")"
End If
Next myCell

End Sub


cmarch wrote:

A formula that finally works (thanks Dave Ritchie) is
=HYPERLINK("#"&CELL("address",Datasheet!C15),Datas heet!C15). I can copy and
it to other cells and also don't get cannot open specified file error

But how do I automate the creation of the the macro from original cell
contents of
=Datasheet!c15 or =+Datasheet!C15 to above hyperlink formula

Thanks very much.
Charles


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro add Hyperlink formula

And it's my passive aggressive way of trying to get everyone to use Option
Explicit!

cmarch wrote:

Never mind, found Option Explicit explanation

"cmarch" wrote:

Thanks Dave, I always find your posts work beautifully. One quick question,
why does it have to have Option Explicit?

Thanks

"Dave Peterson" wrote:

Select the range to change and try this macro:

Option Explicit
Sub testme02()
Dim myRng As Range
Dim myCell As Range
Dim myStr As String

Set myRng = Selection
For Each myCell In myRng.Cells
If myCell.HasFormula Then
myStr = Mid(myCell.Formula, 2)
If Left(myStr, 1) = "+" Then
myStr = Mid(myStr, 2)
End If
'=HYPERLINK("#"&CELL("address",Datasheet!C15),Data sheet!C15)
myCell.Formula = "=hyperlink(""#""&cell(""address""," _
& myStr & ")," & myStr & ")"
End If
Next myCell

End Sub


cmarch wrote:

A formula that finally works (thanks Dave Ritchie) is
=HYPERLINK("#"&CELL("address",Datasheet!C15),Datas heet!C15). I can copy and
it to other cells and also don't get cannot open specified file error

But how do I automate the creation of the the macro from original cell
contents of
=Datasheet!c15 or =+Datasheet!C15 to above hyperlink formula

Thanks very much.
Charles

--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Macro add Hyperlink formula

dave,

I was trying to build off of your formula for inserting a hyperlink but keep
getting a
?NAME error. I am looping through a range of cells that I pre-select and
looking to see if a link is needed. If so I need to build it off of COL A in
the same row (1st 5 chars) and a number based on what iteration of a similar
group it is at.

The link builds but shows up as the literal text and the variable name
literally instead of the value it should contain.
=HYPERLINK("http://www.wilions.org/youthexchange/YEAPPS/"& myStr &
ctryCounter & link_suffix, "link")

How do I get the variables to come through as text?

Sub Create_Hyperlink_based_On_country_Name()
Dim myRng As Range
Dim myCell As Range
Dim myStr As String
Dim ctryCompare As String
Dim Counter As Integer
Dim ctryCounter As Integer
Dim appFormula As String
Dim link_suffix As String

link_suffix = ".pdf"

Counter = 5
myStr = Left(Cells(5, 1), 5)
ctryCompare = myStr
Set myRng = Selection
For Each myCell In myRng.Cells
If myCell.Value = "link" Then ' is a link needed?
myStr = Left(Cells(Counter, 1), 5) ' Yes, so get country
name (5 chars)
If myStr = ctryCompare Then ' Check if new country
ctryCounter = ctryCounter + 1 ' track what # to use
for link
Else: ctryCounter = 1 'New Country
End If

Counter = Counter + 1
myCell.Formula = "=hyperlink(""http://www.website.org/""& myStr
& _
ctryCounter & link_suffix,
""link"")"

Else: Counter = Counter + 1
End If
Next myCell


End Sub
--
Ray Tweedale
"Dave Peterson" wrote:

Select the range to change and try this macro:

Option Explicit
Sub testme02()
Dim myRng As Range
Dim myCell As Range
Dim myStr As String

Set myRng = Selection
For Each myCell In myRng.Cells
If myCell.HasFormula Then
myStr = Mid(myCell.Formula, 2)
If Left(myStr, 1) = "+" Then
myStr = Mid(myStr, 2)
End If
'=HYPERLINK("#"&CELL("address",Datasheet!C15),Data sheet!C15)
myCell.Formula = "=hyperlink(""#""&cell(""address""," _
& myStr & ")," & myStr & ")"
End If
Next myCell

End Sub


cmarch wrote:

A formula that finally works (thanks Dave Ritchie) is
=HYPERLINK("#"&CELL("address",Datasheet!C15),Datas heet!C15). I can copy and
it to other cells and also don't get cannot open specified file error

But how do I automate the creation of the the macro from original cell
contents of
=Datasheet!c15 or =+Datasheet!C15 to above hyperlink formula

Thanks very much.
Charles


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro add Hyperlink formula


Hi
I desperately look for a macro to remove/ delete the hyperlinks which
are already clicked by the users from a set of hyperlinks, the moment
it is clicked. I have a set of hyperlinks in a column, which I set blue
in color.

Please help!!

Thanks a lot

Twinkle


--
twinklejmj
------------------------------------------------------------------------
twinklejmj's Profile: http://www.excelforum.com/member.php...o&userid=27085
View this thread: http://www.excelforum.com/showthread...hreadid=466303

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro add Hyperlink formula

Rightclick on the worksheet tab that has the hyperlinks, then select view code.
Paste this in:

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End With

End Sub

Or maybe...

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
If Intersect(.Cells, Me.Range("e7:h17")) Is Nothing Then
'do nothing
Else
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End If
End With

End Sub

If you want to limit the range.



twinklejmj wrote:

Hi
I desperately look for a macro to remove/ delete the hyperlinks which
are already clicked by the users from a set of hyperlinks, the moment
it is clicked. I have a set of hyperlinks in a column, which I set blue
in color.

Please help!!

Thanks a lot

Twinkle

--
twinklejmj
------------------------------------------------------------------------
twinklejmj's Profile: http://www.excelforum.com/member.php...o&userid=27085
View this thread: http://www.excelforum.com/showthread...hreadid=466303


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default Macro add Hyperlink formula

Hi Dave

I have been looking for some hyperlink help and have found your posts have
been quite helpful to others, and so i thought you may be able to help me
with a problem i am having.

I have a form to enter text (and the text gets copied to a worksheet). But
within the form I would like to add a browse button to find a file, which
then adds the path of that file to colmun H as a hyperlink in the same
worksheet...so that when you click on the hyperlink, the file opens up. The
types of files are normal Word and Excel files which will either be located
on my local drive or a netwrok drive.

It's basically the normal Hyperlink button you get in any MS application,
but I just want it within a form and for the link to be copied into column H5
onwards.

Please let me know if you can help me?



"Dave Peterson" wrote:

Rightclick on the worksheet tab that has the hyperlinks, then select view code.
Paste this in:

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End With

End Sub

Or maybe...

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
If Intersect(.Cells, Me.Range("e7:h17")) Is Nothing Then
'do nothing
Else
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End If
End With

End Sub

If you want to limit the range.



twinklejmj wrote:

Hi
I desperately look for a macro to remove/ delete the hyperlinks which
are already clicked by the users from a set of hyperlinks, the moment
it is clicked. I have a set of hyperlinks in a column, which I set blue
in color.

Please help!!

Thanks a lot

Twinkle

--
twinklejmj
------------------------------------------------------------------------
twinklejmj's Profile: http://www.excelforum.com/member.php...o&userid=27085
View this thread: http://www.excelforum.com/showthread...hreadid=466303


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro add Hyperlink formula

You could add a label to the userform and format the text to look like a
hyperlink (blue, underlined). Then use the Label's _Click event to search for
the file--using application.getopenfilename.

Personally, I would think a browse commandbutton would look more natural to a
user.

Option Explicit
Private Sub Label1_Click()
Dim myFileName As Variant
Dim NextRow As Long

With ActiveSheet
NextRow = .Cells(.Rows.Count, "F").End(xlUp).Row + 1
End With

myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")
If myFileName = False Then
Beep 'do nothing???
Else
ActiveSheet.Cells(NextRow, "F").Formula _
= "=hyperlink(""file:////""&" _
& """" & myFileName & """,""click me"")"
End If

End Sub



zak wrote:

Hi Dave

I have been looking for some hyperlink help and have found your posts have
been quite helpful to others, and so i thought you may be able to help me
with a problem i am having.

I have a form to enter text (and the text gets copied to a worksheet). But
within the form I would like to add a browse button to find a file, which
then adds the path of that file to colmun H as a hyperlink in the same
worksheet...so that when you click on the hyperlink, the file opens up. The
types of files are normal Word and Excel files which will either be located
on my local drive or a netwrok drive.

It's basically the normal Hyperlink button you get in any MS application,
but I just want it within a form and for the link to be copied into column H5
onwards.

Please let me know if you can help me?

"Dave Peterson" wrote:

Rightclick on the worksheet tab that has the hyperlinks, then select view code.
Paste this in:

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End With

End Sub

Or maybe...

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
If Intersect(.Cells, Me.Range("e7:h17")) Is Nothing Then
'do nothing
Else
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End If
End With

End Sub

If you want to limit the range.



twinklejmj wrote:

Hi
I desperately look for a macro to remove/ delete the hyperlinks which
are already clicked by the users from a set of hyperlinks, the moment
it is clicked. I have a set of hyperlinks in a column, which I set blue
in color.

Please help!!

Thanks a lot

Twinkle

--
twinklejmj
------------------------------------------------------------------------
twinklejmj's Profile: http://www.excelforum.com/member.php...o&userid=27085
View this thread: http://www.excelforum.com/showthread...hreadid=466303


--

Dave Peterson


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default Macro add Hyperlink formula

Dave

This is absolutely GREAT, thank you!
Is there any way, where you have said "click me" that I could change this so
that it shows the actual file path?

I have a text input box called DocFilePath in which I want it to show in, on
this userform?

Thanks


"Dave Peterson" wrote:

You could add a label to the userform and format the text to look like a
hyperlink (blue, underlined). Then use the Label's _Click event to search for
the file--using application.getopenfilename.

Personally, I would think a browse commandbutton would look more natural to a
user.

Option Explicit
Private Sub Label1_Click()
Dim myFileName As Variant
Dim NextRow As Long

With ActiveSheet
NextRow = .Cells(.Rows.Count, "F").End(xlUp).Row + 1
End With

myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")
If myFileName = False Then
Beep 'do nothing???
Else
ActiveSheet.Cells(NextRow, "F").Formula _
= "=hyperlink(""file:////""&" _
& """" & myFileName & """,""click me"")"
End If

End Sub



zak wrote:

Hi Dave

I have been looking for some hyperlink help and have found your posts have
been quite helpful to others, and so i thought you may be able to help me
with a problem i am having.

I have a form to enter text (and the text gets copied to a worksheet). But
within the form I would like to add a browse button to find a file, which
then adds the path of that file to colmun H as a hyperlink in the same
worksheet...so that when you click on the hyperlink, the file opens up. The
types of files are normal Word and Excel files which will either be located
on my local drive or a netwrok drive.

It's basically the normal Hyperlink button you get in any MS application,
but I just want it within a form and for the link to be copied into column H5
onwards.

Please let me know if you can help me?

"Dave Peterson" wrote:

Rightclick on the worksheet tab that has the hyperlinks, then select view code.
Paste this in:

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End With

End Sub

Or maybe...

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
If Intersect(.Cells, Me.Range("e7:h17")) Is Nothing Then
'do nothing
Else
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End If
End With

End Sub

If you want to limit the range.



twinklejmj wrote:

Hi
I desperately look for a macro to remove/ delete the hyperlinks which
are already clicked by the users from a set of hyperlinks, the moment
it is clicked. I have a set of hyperlinks in a column, which I set blue
in color.

Please help!!

Thanks a lot

Twinkle

--
twinklejmj
------------------------------------------------------------------------
twinklejmj's Profile: http://www.excelforum.com/member.php...o&userid=27085
View this thread: http://www.excelforum.com/showthread...hreadid=466303

--

Dave Peterson


--

Dave Peterson

  #12   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default Macro add Hyperlink formula

Hi Dave

Please ignore my previous message. I added the msgBox line in and got a
message saying 1048577 followed by the text i entered in the OwnerN text
input box.

Any ideas?

Thanks



"Dave Peterson" wrote:

You could add a label to the userform and format the text to look like a
hyperlink (blue, underlined). Then use the Label's _Click event to search for
the file--using application.getopenfilename.

Personally, I would think a browse commandbutton would look more natural to a
user.

Option Explicit
Private Sub Label1_Click()
Dim myFileName As Variant
Dim NextRow As Long

With ActiveSheet
NextRow = .Cells(.Rows.Count, "F").End(xlUp).Row + 1
End With

myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")
If myFileName = False Then
Beep 'do nothing???
Else
ActiveSheet.Cells(NextRow, "F").Formula _
= "=hyperlink(""file:////""&" _
& """" & myFileName & """,""click me"")"
End If

End Sub



zak wrote:

Hi Dave

I have been looking for some hyperlink help and have found your posts have
been quite helpful to others, and so i thought you may be able to help me
with a problem i am having.

I have a form to enter text (and the text gets copied to a worksheet). But
within the form I would like to add a browse button to find a file, which
then adds the path of that file to colmun H as a hyperlink in the same
worksheet...so that when you click on the hyperlink, the file opens up. The
types of files are normal Word and Excel files which will either be located
on my local drive or a netwrok drive.

It's basically the normal Hyperlink button you get in any MS application,
but I just want it within a form and for the link to be copied into column H5
onwards.

Please let me know if you can help me?

"Dave Peterson" wrote:

Rightclick on the worksheet tab that has the hyperlinks, then select view code.
Paste this in:

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End With

End Sub

Or maybe...

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
If Intersect(.Cells, Me.Range("e7:h17")) Is Nothing Then
'do nothing
Else
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End If
End With

End Sub

If you want to limit the range.



twinklejmj wrote:

Hi
I desperately look for a macro to remove/ delete the hyperlinks which
are already clicked by the users from a set of hyperlinks, the moment
it is clicked. I have a set of hyperlinks in a column, which I set blue
in color.

Please help!!

Thanks a lot

Twinkle

--
twinklejmj
------------------------------------------------------------------------
twinklejmj's Profile: http://www.excelforum.com/member.php...o&userid=27085
View this thread: http://www.excelforum.com/showthread...hreadid=466303

--

Dave Peterson


--

Dave Peterson

  #13   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default Macro add Hyperlink formula

Some good news........Please ignore my last e-mail Dave.

I have got the code working now somehow. Thanks for all of your help on
this. I really appreciate it.

Thanks

"Dave Peterson" wrote:

You could add a label to the userform and format the text to look like a
hyperlink (blue, underlined). Then use the Label's _Click event to search for
the file--using application.getopenfilename.

Personally, I would think a browse commandbutton would look more natural to a
user.

Option Explicit
Private Sub Label1_Click()
Dim myFileName As Variant
Dim NextRow As Long

With ActiveSheet
NextRow = .Cells(.Rows.Count, "F").End(xlUp).Row + 1
End With

myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")
If myFileName = False Then
Beep 'do nothing???
Else
ActiveSheet.Cells(NextRow, "F").Formula _
= "=hyperlink(""file:////""&" _
& """" & myFileName & """,""click me"")"
End If

End Sub



zak wrote:

Hi Dave

I have been looking for some hyperlink help and have found your posts have
been quite helpful to others, and so i thought you may be able to help me
with a problem i am having.

I have a form to enter text (and the text gets copied to a worksheet). But
within the form I would like to add a browse button to find a file, which
then adds the path of that file to colmun H as a hyperlink in the same
worksheet...so that when you click on the hyperlink, the file opens up. The
types of files are normal Word and Excel files which will either be located
on my local drive or a netwrok drive.

It's basically the normal Hyperlink button you get in any MS application,
but I just want it within a form and for the link to be copied into column H5
onwards.

Please let me know if you can help me?

"Dave Peterson" wrote:

Rightclick on the worksheet tab that has the hyperlinks, then select view code.
Paste this in:

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End With

End Sub

Or maybe...

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
If Intersect(.Cells, Me.Range("e7:h17")) Is Nothing Then
'do nothing
Else
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End If
End With

End Sub

If you want to limit the range.



twinklejmj wrote:

Hi
I desperately look for a macro to remove/ delete the hyperlinks which
are already clicked by the users from a set of hyperlinks, the moment
it is clicked. I have a set of hyperlinks in a column, which I set blue
in color.

Please help!!

Thanks a lot

Twinkle

--
twinklejmj
------------------------------------------------------------------------
twinklejmj's Profile: http://www.excelforum.com/member.php...o&userid=27085
View this thread: http://www.excelforum.com/showthread...hreadid=466303

--

Dave Peterson


--

Dave Peterson

  #14   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default Macro add Hyperlink formula

Hi Dave

I have not solved my hyperlink issues also, so please can you still offer
your help on this. My query yesterday was - Is there any way, where you have
said "click me" that I could change this so that it shows the actual file
path?

I have a text input box called DocFilePath in which I want the link to show
in, on
this userform?

This is the code I have at the moment:

Private Sub CommandButton4_Click()
Dim myFileName As Variant
Dim NextRow As Long

With ActiveSheet
NextRow = .Cells(.Rows.Count, "I").End(xlUp).Row + 1
End With

myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")
If myFileName = False Then
Beep 'do nothing???
Else
ActiveSheet.Cells(NextRow, "I").Formula _
= "=hyperlink(""file:////""&" _
& """" & myFileName & """,""click me"")"
End If
End Sub

Thanks Dave, sorry for the mix up.



"Dave Peterson" wrote:

You could add a label to the userform and format the text to look like a
hyperlink (blue, underlined). Then use the Label's _Click event to search for
the file--using application.getopenfilename.

Personally, I would think a browse commandbutton would look more natural to a
user.

Option Explicit
Private Sub Label1_Click()
Dim myFileName As Variant
Dim NextRow As Long

With ActiveSheet
NextRow = .Cells(.Rows.Count, "F").End(xlUp).Row + 1
End With

myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")
If myFileName = False Then
Beep 'do nothing???
Else
ActiveSheet.Cells(NextRow, "F").Formula _
= "=hyperlink(""file:////""&" _
& """" & myFileName & """,""click me"")"
End If

End Sub



zak wrote:

Hi Dave

I have been looking for some hyperlink help and have found your posts have
been quite helpful to others, and so i thought you may be able to help me
with a problem i am having.

I have a form to enter text (and the text gets copied to a worksheet). But
within the form I would like to add a browse button to find a file, which
then adds the path of that file to colmun H as a hyperlink in the same
worksheet...so that when you click on the hyperlink, the file opens up. The
types of files are normal Word and Excel files which will either be located
on my local drive or a netwrok drive.

It's basically the normal Hyperlink button you get in any MS application,
but I just want it within a form and for the link to be copied into column H5
onwards.

Please let me know if you can help me?

"Dave Peterson" wrote:

Rightclick on the worksheet tab that has the hyperlinks, then select view code.
Paste this in:

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End With

End Sub

Or maybe...

Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

With Target.Parent
If Intersect(.Cells, Me.Range("e7:h17")) Is Nothing Then
'do nothing
Else
.Hyperlinks.Delete
.ClearContents '??? clear the cell, too???
End If
End With

End Sub

If you want to limit the range.



twinklejmj wrote:

Hi
I desperately look for a macro to remove/ delete the hyperlinks which
are already clicked by the users from a set of hyperlinks, the moment
it is clicked. I have a set of hyperlinks in a column, which I set blue
in color.

Please help!!

Thanks a lot

Twinkle

--
twinklejmj
------------------------------------------------------------------------
twinklejmj's Profile: http://www.excelforum.com/member.php...o&userid=27085
View this thread: http://www.excelforum.com/showthread...hreadid=466303

--

Dave Peterson


--

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
Macro in Hyperlink adeel via OfficeKB.com Excel Discussion (Misc queries) 1 July 3rd 09 08:31 PM
Hyperlink to a Macro pokdbz Excel Discussion (Misc queries) 4 October 4th 07 08:18 PM
Hyperlink Macro Diane Excel Discussion (Misc queries) 0 September 25th 06 04:51 PM
Intra-workbook hyperlink: macro/function to return to hyperlink ce marika1981 Excel Discussion (Misc queries) 3 May 6th 05 05:47 AM
Macro to Copy Hyperlink to another file as a HYPERLINK, not text... dollardoc Excel Programming 1 April 7th 05 12:47 AM


All times are GMT +1. The time now is 08:51 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"