A Macro that will create a hyperlink in one cell from other cell references

CUP'O'JEY

New Member
Joined
Jul 27, 2010
Messages
9
Good Morning / Afternoon All

I was wondering if I could some help on this

  1. I have an excel spreadsheet that lists various drawings on a column called SIGN DESIGN NUMBER. The cell contents on the picture 'E10' is based on the file name of the drawing in .PDF
  2. In the nearby cell 'E9' I would like to create a hyperlink for the file
to do this I use a macro in another instance of excel and extract all the pdfs from a common directory and then cut the found hyperlinks and pasting the cells into 'E9'

is it possible to create a macro that says based on the contents of of one cell find the pdf and create a hyperlink

i tried to use lookup that would reference the second spreadsheet but it went all a little wonky when things werent in the right order

Overall I want to be able to create a macro that will extract all the information I need rather than cut and past please help

I hope the link works

http://picasaweb.google.com/105445792613342177386/PleaseHelp?feat=directlink

but here is the code is used to list all the pdf's in my directory

Code:
Option Explicit
 
Sub SrchForFiles()
     ' Searches the selected folders and sub folders for files with the specified
     'extension.  .xls, .doc, .ppt, etc.
     'A new worksheet is produced called "File Search Results".  You can click on the link and go directly
     'to the file you need.
    Dim i As Long, z As Long, Rw As Long
    Dim ws As Worksheet
    Dim y As Variant
    Dim fLdr As String, Fil As String, FPath As String
 
    y = Application.InputBox("Please Enter File Extension", "Info Request")
    If y = False And Not TypeName(y) = "String" Then Exit Sub
    Application.ScreenUpdating = False
     '**********************************************************************
     'fLdr = BrowseForFolderShell
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Show
        fLdr = .SelectedItems(1)
    End With
     '**********************************************************************
    With Application.FileSearch
        .NewSearch
        .LookIn = fLdr
        .SearchSubFolders = True
        .Filename = y
        Set ws = ThisWorkbook.Worksheets.Add(Sheets(1))
        On Error GoTo 1
2:                      ws.Name = "FileSearch Results"
        On Error GoTo 0
        If .Execute() > 0 Then
            For i = 1 To .FoundFiles.Count
                Fil = .FoundFiles(i)
                 'Get file path from file name
                FPath = Left(Fil, Len(Fil) - Len(Split(Fil, "\")(UBound(Split(Fil, "\")))) - 1)
                If Left$(Fil, 1) = Left$(fLdr, 1) Then
                    If CBool(Len(Dir(Fil))) Then
                        z = z + 1
                        ws.Cells(z + 1, 1).Resize(, 4) = _
                        Array(Dir(Fil), _
                        FileLen(Fil) / 1000, _
                        FileDateTime(Fil), _
                        FPath)
                        ws.Hyperlinks.Add Anchor:=Cells(z + 1, 1), _
                        Address:=.FoundFiles(i)
                    End If
                End If
            Next i
        End If
    End With
 
    ActiveWindow.DisplayHeadings = False
 
    With ws
        Rw = .Cells.Rows.Count
        With .[A1:D1]
            .Value = [{"Full Name","Kilobytes","Last Modified", "Path"}]
            .Font.Underline = xlUnderlineStyleSingle
            .EntireColumn.AutoFit
            .HorizontalAlignment = xlCenter
        End With
        .[E1:IV1 ].EntireColumn.Hidden = True
        On Error Resume Next
        Range(Cells(Rw, "A").End(3)(2), Cells(Rw, "A")).EntireRow.Hidden = True
        Range(.[A2 ], Cells(Rw, "C")).Sort [A2 ], xlAscending, Header:=xlNo
    End With
 
    Application.ScreenUpdating = True
    Exit Sub
1:          Application.DisplayAlerts = False
    Worksheets("FileSearch Results").Delete
    Application.DisplayAlerts = True
    GoTo 2
End Sub


I then sit down and go about extracting by cutting and pasting

arrrrrgh there must be something easier
 
I looked at your screenshot, which is almost too small to be of use. However, the values in column E, are they the name of the file you want to link to?
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Is it something like this you are hoping to achieve?
Excel Workbook
CDE
1
2
3D:\forskning\Baskerville Action Research in IS.pdfBaskerville Action Research in IS
Sheet2
Excel 2007
Cell Formulas
RangeFormula
D3=HYPERLINK("D:\forskning\" & E3 & ".pdf")
 
Upvote 0
YES thanks snowblizz thats exactly it but on a larger scale so some macro would advice as to what to write or where i might be going wrong

cheers
 
Upvote 0
i could but then where would all the fun coding time go

any help at all would be appreciated

think of it as charity to those less fortunate vb scripters out here cyber space that dont have the vast amounts of knowledge that you guys do


wow that is some impressive grovelling right there
 
Upvote 0

Forum statistics

Threads
1,215,420
Messages
6,124,803
Members
449,190
Latest member
cindykay

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