Adding Hyperlink title

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
779
Office Version
  1. 365
Found code below, how to modify it that display a title instead of whole link.

VBA Code:
.   
Sub Test()
Dim fd As FileDialog
Dim FilePicked As Integer
Dim UserRange As Range, UserCell As Range

Set fd = Application.FileDialog(msoFileDialogFilePicker)
' Change initial folder as needed or store it in a cell and reference that
fd.InitialFileName = "c:\Temp\"
fd.AllowMultiSelect = True
FilePicked = fd.Show

If FilePicked = 0 Then
    MsgBox "You hit cancel"
Else
    'Using inputbox to get selected Range
    Set UserRange = Application.InputBox(Prompt:="Please Select a Cell", Title:="Cell Select", Type:=8)
    'Get first cell of selected range
    Set UserCell = UserRange.Cells(1)
  
    'loop through selecteditems from FileDialog and create hyperlink offsetting cell by 1 column each time
    For i = 1 To fd.SelectedItems.Count
      UserCell.Hyperlinks.Add Anchor:=UserCell, Address:=fd.SelectedItems(i)
      Set UserCell = UserCell.Offset(0, 1)
    Next
End If

End Sub

Thank you
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try:
Rich (BB code):
    'loop through selecteditems from FileDialog and create hyperlink offsetting cell by 1 column each time
    Dim ary
    For i = 1 To fd.SelectedItems.Count
    ary = Split(fd.SelectedItems(i), "\")
    UserCell.Hyperlinks.Add Anchor:=UserCell, Address:=fd.SelectedItems(i), TextToDisplay:=ary(UBound(ary))
      Set UserCell = UserCell.Offset(0, 1)
    Next
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,483
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top