E
excelhurtsme
I have an event macro on worksheet, works beautifully when worksheet is
unprotected but will not when the sheet is protected. Gives me "unable to set
the ColumnWidth property of the Range Class" error. The event Macro looks
like this
Private Sub Worksheet_SelectionChange (ByVal Target As Range)
Dim myRng As Range
Set myRng = Me.Range("A10:A16,A22:A33,A37:A46,G22:G33").EntireColumn
If Target.Count > 1 Then Exit Sub
'reset all those column widths
myRng.ColumnWidth = 7
If Intersect(Target, myRng) Is Nothing Then
'do nothing
Else
Target.EntireColumn.ColumnWidth = 20
End If
End Sub
unprotected but will not when the sheet is protected. Gives me "unable to set
the ColumnWidth property of the Range Class" error. The event Macro looks
like this
Private Sub Worksheet_SelectionChange (ByVal Target As Range)
Dim myRng As Range
Set myRng = Me.Range("A10:A16,A22:A33,A37:A46,G22:G33").EntireColumn
If Target.Count > 1 Then Exit Sub
'reset all those column widths
myRng.ColumnWidth = 7
If Intersect(Target, myRng) Is Nothing Then
'do nothing
Else
Target.EntireColumn.ColumnWidth = 20
End If
End Sub