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


So please solve my problem….



By: Md Mamun

214 thoughts on “How to add multiple VBA codes on one worksheet

  1. Brianvogue

    Howdy, well put together webpage you possess right now.


  2. jordans

    I want to express some thanks to this writer for rescuing me from this issue. As a result of surfing around through the world-wide-web and obtaining concepts that were not pleasant, I was thinking my entire life was done. Living without the solutions to the issues you have resolved all through your entire website is a critical case, and the ones which might have badly affected my career if I hadn’t discovered your website. Your actual talents and kindness in handling all things was vital. I’m not sure what I would’ve done if I hadn’t encountered such a point like this. I can now look forward to my future. Thanks very much for the expert and effective help. I won’t hesitate to refer your blog to any person who should get guidelines on this subject.

  3. ban da nha tam

    Wonderful work! This is the type of information that should be shared around the web. Shame on Google for not positioning this post higher! Come on over and visit my website. Thanks =)

  4. buy CBD oil

    Thank you for another wonderful article. Where else could anyone get that kind of info in such a perfect way of writing? I have a presentation next week, and I am on the look for such info.

Leave a Reply

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