+ Reply to Thread
Results 1 to 4 of 4

lock cells after data entry

Hybrid View

aleenkhan lock cells after data entry 08-06-2012, 01:17 AM
mmmarks Re: lock cells after data... 08-06-2012, 02:14 AM
aleenkhan Re: lock cells after data... 08-06-2012, 02:40 AM
mmmarks Re: lock cells after data... 08-06-2012, 03:14 AM
  1. #1
    Registered User
    Join Date
    03-02-2011
    Location
    India
    MS-Off Ver
    Excel 2003/2010
    Posts
    38

    lock cells after data entry

    Hi,

    The below code works for column A and B. When I enter data in any row in column A (lets say A1), the adjacent row in column B i.e., B1 will take a times stamp and then every row having data in it (i.e., A1 and B1 in this example) will get locked.

    What I am looking for is the code which do the same thing but for column C and column D also.

    Below is the code which i m using in Worksheet module :

    
    Option Explicit 
     
    Private Sub Worksheet_SelectionChange(ByVal Target As Range) 
        If Target.Column > 2 Then Exit Sub 'only works in Columns A & B
        With ActiveSheet 
            .Unprotect 
            If Target.Value > "" Then Target.Locked = True 
            .Protect 
        End With 
    End Sub
    Can someone help?

    Thanks in advance.

    Aleen
    Last edited by aleenkhan; 08-06-2012 at 01:25 AM.

  2. #2
    Forum Contributor
    Join Date
    11-26-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    159

    Re: lock cells after data entry

    hi ,
    something like this...
    Private Sub Worksheet_Change(ByVal Target As Range)
       If Target.Column = 3 Then
            If Target.Value <> "" Then Target.Offset(0, 1).Value = Time
            End If
            
            
    End Sub

  3. #3
    Registered User
    Join Date
    03-02-2011
    Location
    India
    MS-Off Ver
    Excel 2003/2010
    Posts
    38

    Re: lock cells after data entry

    it doesn't work at all.

  4. #4
    Forum Contributor
    Join Date
    11-26-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    159

    Re: lock cells after data entry

    It will work.
    right click on worksheet(A sheet where you want to make changes) TAB-->View Code. and Paste there.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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