+ Reply to Thread
Results 1 to 2 of 2

Lock cell after data is entered???

  1. #1
    Registered User
    Join Date
    01-25-2012
    Location
    Canton, Oh
    MS-Off Ver
    Excel 2010
    Posts
    1

    Lock cell after data is entered???

    I am trying to create an invoice sheet for my computer shop. I have never used excel really unless it was created for me.

    My issue is that I want to lock a couple of cells after data is entered for example cells B13, C13, and H13 on sheet2 and so on.

    I tried creating a macro

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim myRange As Range
    On Error Resume Next
    Set myRange = Intersect(Range("C13,B13,H13"), Target)
    If Not myRange Is Nothing Then
    Me.Unprotect
    Target.Cells.Locked = True
    Me.Protect
    End If

    End Sub


    But it then locks all after the first one is entered. How can I set them to lock after only they are filled?
    Attached Files Attached Files

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Lock cell after data is entered???

    Per the rule you agreed to follow, all VBA code must be wrapped in code tags.

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]

    You cross posted at Ozgrid. This is one of the more serious violations of the forums rules.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1