jeh
jeh

Reputation: 31

This routine does not work in protect mode

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Dim rg As Range
Set rg = Intersect(Target, Range("A1:J10"))
If Not rg Is Nothing And Range("V7") = "YES" Then
[RowNo] = ActiveCell.Row
[ColNo] = ActiveCell.Column

End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
 If Not Intersect(Target, Range("V7")) Is Nothing Then
    If Target = "NO" Then [AK1:AL1] = 0
End If
End Sub

The above SelectionChange does not work when the sheet is in protect mode. Is there any way to correct this. In protect mode it hangs up on the line that says [RowNo] = ActiveCell.Row. This works correctly when sheet is unprotected.

Upvotes: 2

Views: 58

Answers (1)

Tim Williams
Tim Williams

Reputation: 166196

Like this:

'...
Me.Unprotect                  'in a sheet module Me=the sheet
[RowNo] = ActiveCell.Row
[ColNo] = ActiveCell.Column
Me.Protect
'...

Upvotes: 3

Related Questions