How to add multiple VBA codes on one worksheet

Hello there, I want to lock particular culumn.. i want them to be automatically locked after the value is change… and i tried this code..

Private Sub Worksheet_Change(ByVal Target As Range)

    Dim MyRange As Range

 

    Set MyRange = Intersect(Range(“C56:C72”), Target)

    If Not MyRange Is Nothing Then

        Sheets(“Sheet1″).Unprotect Password:=”HELLO”

        MyRange.Locked = True

        Sheets(“Sheet1″).Protect Password:=”HELLO”

    End If

End Sub

 

i want to use this same code expect This Line twice in a same worksheet

Set MyRange = Intersect(Range(“C56:C72”), Target) ,I want to change the value of this line from “C56:C72” to “C6:AI36”

But when i try to do this, i always get an error called  Ambiguous

error…

So please solve my problem….

 

 

By: Md Mamun

Leave a Reply

Your email address will not be published. Required fields are marked *