Hi Harish.
You will need to copy the following code to the appropriate Worksheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim uName As String
Dim closeColNum As Integer
'Call your UDF to return the current user's username
uName = username
'Change this to the column number appropriate for your "Closed By" column
closeColNum = 2
'Only check if the "Closed By" column has been changed
If Target.Column = closeColNum Then
If Target.Value <> uName Then
'Username and closed by value don't match
MsgBox "Sorry " & uName & ", you are not authorised to close this entry."
'Disable events so that cell can be emptied without triggering this macro again
Application.EnableEvents = False
'Reset the cell value to blank
Target.Value = ""
'Re-enable events so that future changes trigger this macro
Application.EnableEvents = True
End If
End If
End Sub
This macro assumes that the "Closed By" column is column 2 (Column "B"), but change this within the code to the appropriate column for your situation.
Hope this helps
Bookmarks