i'm recalling string column in excel worksheet. take string , match file name in windows explorer, creating hyperlink file.
so far, can loop through set of file names , return message box. return string name search in windows explorer. code far:
sub looprange() dim currrow integer, lastrow integer dim ws string, quoteid string ws = "quote log" currrow = 3 lastrow = sheets(ws).cells(sheets(ws).rows.count, "a").end(xlup).row while currrow <= lastrow sheets(ws).cells(currrow, 1).select quoteid = activecell.value msgbox "you've selected row " & currrow & ", " & _ vbnewline & "quote id: " & quoteid currrow = currrow + 1 wend end sub
you can use dir function check whether file exists - pass in full path , filename. return empty string if file not exist. i've inserted hyperlink in cell left of quote, can adjust needed:
sub looprange() dim currrow integer, lastrow integer dim ws string, quoteid string dim path string dim filename string path = "d:\documents\" ws = "quote log" currrow = 3 lastrow = sheets(ws).cells(sheets(ws).rows.count, "a").end(xlup).row while currrow <= lastrow sheets(ws).cells(currrow, 1).select quoteid = activecell.value filename = path & quoteid & ".xlsx" if dir(filename) <> "" , quoteid <> "" sheets(ws).hyperlinks.add anchor:=cells(currrow, 2), address:=filename, texttodisplay:=quoteid end if currrow = currrow + 1 wend end sub
Comments
Post a Comment