Why does this create the hyperlink on the activesheet and not on the employee sheet?
[VBA]
Sub Last_Created_Hyperlink_Test()
Dim fso As New FileSystemObject
Dim fls As Files
Dim i As Integer
Dim Picfile, MyFile As Variant
Dim Mc As Range
Set fls = fso.GetFolder("C:\Documents and Settings\Simon\Desktop\new pics\Staff ID Photos").Files
i = 2
With Worksheets("Photo Details")
.Cells(1, 1) = "File Name"
.Cells(1, 2) = "File Size"
.Cells(1, 3) = "Date Created"
.Cells(1, 4) = "Link To Photo"
.Cells(1, 5) = "LookUp Value"
For Each Picfile In fls
MyFile = "C:\Documents and Settings\Simon\Desktop\new pics\Staff ID Photos\" & Picfile.Name
.Cells(i, 1) = Picfile.Name
.Cells(i, 2) = Picfile.Size
.Cells(i, 3) = Picfile.DateCreated
With Sheets("Employee Details")
Set Mc = Cells.Find(What:=Worksheets("Photo Details").Cells(i, 5).Value, After:=.Cells(1, 1), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Mc.Offset(0, 11).Hyperlinks.Add Anchor:=Mc.Offset(0, 11), Address:=MyFile, TextToDisplay:="Yes"
End With
i = i + 1
Next
End With
Columns("A:E").AutoFit
End Sub
[/VBA]Any ideas?
Regards,
Simon