Excel MS Excel 2000 Select hyperlink on a macro enabled protected sheet

Joined
Jun 4, 2012
Messages
9
Reaction score
0
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
 
I tried this on my machine and it was caused when the sheet name wasn't 'Summary of Contracts'. Suggest you need to check the sheet name, if you don't use the sheet names then you could use sheets(1).unprotect etc. But thats not a great idea either!
 
Back
Top