This is a code that creates a value in a cell based on the previous line number, it then hyperlinks this cell to the associated file folder for that Inspection number
Range "G" is the cell to receive the hyperlink.
=SUM(R[-1]C[-6]+1)" Takes the previous line number in from one row above column A, and adds 1.
(example)
Row A = 13 but is custom number formatted ("IR"0000)to show IR0013
Row G is also custom number formatted so it will now show IR0014 next line down when macro runs.
When the hyperlink is created using this cell value it deletes the leading zeros so the end address shows "R:\ Construction\PSI-1\PS\QS\ IR Requests \IR14"
(The target files for link are named containing leading zeros)
It doesn’t seem to matter how I format or name the recipient cell in range G, it always drops the leading zeros in the hyperlink address.
To bypass this I have added two zeros after "IR" in the S.Hyperlinks.Add" string which works but needs to be changed manually as numbers grow from tens to hundreds etc.
Any help on this would be greatly apreciated as i have run out of ideas.
Range("G" & (ActiveCell.Row)).Select
ActiveCell = "=SUM(R[-1]C[-6]+1)"
Dim S As Range
For Each S In Intersect(ActiveCell(r1c1), ActiveSheet.UsedRange)
v = S.Value
If v <> "" Then
S.Hyperlinks.Add anchor:=Selection, Address:="R:\Construction\PSI-1\PS\QS\ IR Requests\IR00" & v + 1
End If
Next S
Range "G" is the cell to receive the hyperlink.
=SUM(R[-1]C[-6]+1)" Takes the previous line number in from one row above column A, and adds 1.
(example)
Row A = 13 but is custom number formatted ("IR"0000)to show IR0013
Row G is also custom number formatted so it will now show IR0014 next line down when macro runs.
When the hyperlink is created using this cell value it deletes the leading zeros so the end address shows "R:\ Construction\PSI-1\PS\QS\ IR Requests \IR14"
(The target files for link are named containing leading zeros)
It doesn’t seem to matter how I format or name the recipient cell in range G, it always drops the leading zeros in the hyperlink address.
To bypass this I have added two zeros after "IR" in the S.Hyperlinks.Add" string which works but needs to be changed manually as numbers grow from tens to hundreds etc.
Any help on this would be greatly apreciated as i have run out of ideas.
Range("G" & (ActiveCell.Row)).Select
ActiveCell = "=SUM(R[-1]C[-6]+1)"
Dim S As Range
For Each S In Intersect(ActiveCell(r1c1), ActiveSheet.UsedRange)
v = S.Value
If v <> "" Then
S.Hyperlinks.Add anchor:=Selection, Address:="R:\Construction\PSI-1\PS\QS\ IR Requests\IR00" & v + 1
End If
Next S