• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to be revised with couple of options

Raju Nagavelli

New Member
I should be able to cells with certain strings in J Column, and whenever I change text in J column the auto date should be updated in next column cell. for example, if I change the text in J3 column then the change date should be updated in column cell like (L3,M3,N3 and O3 ) and locked. So I should be able to change the text in 5 times and 5 auto dates should be updated. After that I should not be allowed to edit that particular cell after 5 changes.

Here is the code and you find the file in the attachment.
>>> use code - tags <<<
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   
    Dim x As Integer
   
    x = 2
    With Sheets("sheet2")
        .Unprotect "test"
        .Cells.Locked = False
    End With
   
    For x = 2 To 32
        If WorksheetFunction.CountA(Range(Cells(x, 1), Cells(x, 10))) <> 0 And Cells(x, 11).Value = "" Then
            Cells(x, 11).Value = Date
        Else: GoTo ende
        End If
        ende:
    Next x
    Call nottoday
End Sub

Sub nottoday()
    For x = 2 To 32
        If IsDate(Cells(x, 11).Value) And Cells(x, 11).Value < Date Then
            ActiveSheet.Unprotect Password:="test"
            Range(Cells(x, 1), Cells(x, 11)).Locked = True
        End If
    Next x
    Sheets("Sheet2").Protect "test"
End Sub
 

Attachments

  • Autodate - Copy.xlsm
    27 KB · Views: 2
Last edited by a moderator:

Raju Nagavelli

Something like this ...?
Protection is not necessary with Your case.
If You really need to use it, then do it with UserinterfaceOnly -option
... then You can avoid swapping Protect <> UnProtect
 

Attachments

  • Autodate - Copy.xlsm
    29.9 KB · Views: 0
Back
Top