I have a sheet of Photo names in numerical order like 23.jpg or 235.jpg and some 1000 others,
this corresponds to a samples 23 or 235 so the photo of sample 23 is different a sample from 235.
But the "find" is finding looking for a 23 but returns 235 becasue the first two characters match. How can I keep it from doing that?
the photo for 235 is not the correct photo for 23
here is my code
DougP
this corresponds to a samples 23 or 235 so the photo of sample 23 is different a sample from 235.
But the "find" is finding looking for a 23 but returns 235 becasue the first two characters match. How can I keep it from doing that?
the photo for 235 is not the correct photo for 23
here is my code
Code:
Sub createPhotoHyperlink()
On Error GoTo Err_Handler
'run this 4th
' this sub creates a hyperlink based on the sample number
' like so ../photos/PE-1234.jpg
Dim SampleNum, WEBURL, MakeHyperlink As String
With Worksheets("Unit 1").Range("C8:C300")
For a = 8 To 300
SampleNum = Cells(a, 3).Value
'find the sample number in the PhotoNames sheet
Set r = Worksheets("PhotoNames").Range("b1:b1500").Find(SampleNum)
PhotoName = Worksheets("PhotoNames").Cells(r.Row, 1)
Worksheets("PhotoNames").Cells(r.Row, 3) = "GotIt"
WEBURL = "../photos/" & SampleNum & ".jpg"
MakeHyperlink = "=HYPERLINK(" & Chr(34) & WEBURL & Chr(34) & "," & Chr(34) & PhotoName & Chr(34) & ")"
Cells(a, 15).Value = MakeHyperlink
nextrec:
Next
End With
Exit_createPhotoHyperlink:
Exit Sub
Err_Handler:
Select Case Err.Number
Case 91
Resume nextrec
Case Else
MsgBox Err.Number & "-" & Err.Description
End Select
Resume 'Exit_createPhotoHyperlink
End Sub
DougP