Consulting

Results 1 to 2 of 2

Thread: Cells Clearcontents

  1. #1
    VBAX Newbie
    Joined
    Sep 2013
    Posts
    2
    Location

    Cells Clearcontents

    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

  2. #2

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •