Hello
I have an Excel worksheet which has various columns. One is a column that has ID numbers in. Each ID number relates to a .txt file called the same as the ID number(which are located in the same folder). In the column next to this i want to place a hyperlink that references the .txt file matching the ID number. I have a lot of ID numbers so manually doing this is going to take forever and its also an on going project.
After lots of help from skie and mrmovie i have the following macro:
Sub MakeALink()
intEndRow = 300
For intRow = 2 To intEndRow
strCell = "D" + Trim(Str(intRow))
If Range(strCell) <> "" Then
strLink = "c:\temp" _
& Range(strCell).Value & ".txt"
ActiveSheet.Hyperlinks.Add Anchor:=Cells(intRow, "E"), _
Address:=strLink, TextToDisplay:="Click Here"
End If
Next
End Sub
This works well except i need it to add a hyperlink for every new cell i add an ID to (at present it will only do this everytime i run the macro and change the cell reference).
mrmovie suggested using the onchange option in excel but ive no idea how to use it. Im not very good with VB so any help would be appreciated.
Thanks
Rob
I have an Excel worksheet which has various columns. One is a column that has ID numbers in. Each ID number relates to a .txt file called the same as the ID number(which are located in the same folder). In the column next to this i want to place a hyperlink that references the .txt file matching the ID number. I have a lot of ID numbers so manually doing this is going to take forever and its also an on going project.
After lots of help from skie and mrmovie i have the following macro:
Sub MakeALink()
intEndRow = 300
For intRow = 2 To intEndRow
strCell = "D" + Trim(Str(intRow))
If Range(strCell) <> "" Then
strLink = "c:\temp" _
& Range(strCell).Value & ".txt"
ActiveSheet.Hyperlinks.Add Anchor:=Cells(intRow, "E"), _
Address:=strLink, TextToDisplay:="Click Here"
End If
Next
End Sub
This works well except i need it to add a hyperlink for every new cell i add an ID to (at present it will only do this everytime i run the macro and change the cell reference).
mrmovie suggested using the onchange option in excel but ive no idea how to use it. Im not very good with VB so any help would be appreciated.
Thanks
Rob