PDA

View Full Version : Cells Clearcontents



Emma_B
09-10-2013, 01:39 AM
Hi,
I need your help to check what is wrong with the followibng code. I want the function of clear contents to work based on the value of B4. If I run the code with clear content part excel crushes.




Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B4") = "Basic" Then ''*** B4 is adropdown ***''
ActiveSheet.Unprotect
'Range("B10,F10,H10").ClearContents ''*** if I run this part the excel crushes ***'''
Range("B10,F10,H10").Locked = True
Range("D10").Locked = False
ActiveSheet.Protect
Else
ActiveSheet.Unprotect
Range("B10,F10,H10").Locked = False
'Range("D10").ClearContents ''*** if I run this part the excel crushes ***'''
Range("D10").Locked = True
ActiveSheet.Protect
End If
End Sub


Thanks in advance

HaHoBe
09-10-2013, 03:34 AM
cross post: http://www.ozgrid.com/forum/showthread.php?t=182492