Hi. I have a select range of cells with a set of code that unprotects the sheet when selected in order to allow hyperlinks to be created.
However when I select an active hyperlink in one of those cells it gives me the following error even though it works correctly:
Run-time error '9':
Subscript out of range
The code is as follows:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 13 Then
Sheets("Summary of Contracts").Unprotect Password:=""
Else
Sheets("Summary of Contracts").Protect Password:=""
End If
End Sub
I would like to ask whether this error can be avoided or whether some coding can be added to hide/remove the error message itself.
Thanks
However when I select an active hyperlink in one of those cells it gives me the following error even though it works correctly:
Run-time error '9':
Subscript out of range
The code is as follows:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 13 Then
Sheets("Summary of Contracts").Unprotect Password:=""
Else
Sheets("Summary of Contracts").Protect Password:=""
End If
End Sub
I would like to ask whether this error can be avoided or whether some coding can be added to hide/remove the error message itself.
Thanks