how do i create worksheet change event only for a specific column i.e. q:q

123amitjain

New Member
Joined
Sep 10, 2013
Messages
5
the below codes are for entire sheet , but i just want to run the just for the entire column q
i just want to lock the column q for the entry just for one time.
how do i ?
i tried many times ....can anybody help me?






Private Sub Worksheet_Change(ByVal Target As Range)
Dim cl As Range


ActiveSheet.Unprotect

For Each cl In Target
If cl.Value <> "" Then
check = MsgBox("is this entry correct? this cell cant be edited after once entered", vbYesNo, "cell Lock Notification")
If check = vbYes Then
cl.Locked = True
Else
End If
End If
Next cl
ActiveSheet.Protect
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Will you be changing one cell at a time, or multiple cells?
 
Upvote 0
Ok, how about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Or Target.Value = "" Then Exit Sub
   If Not Intersect(Target, Range("Q:Q")) Is Nothing Then
      Me.Unprotect
      If MsgBox("is this entry correct? this cell cant be edited after once entered", vbYesNo, "cell Lock Notification") = vbYes Then
         Target.Locked = True
      End If
      Me.Protect
   End If
End Sub
 
Upvote 0
Ok, how about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Or Target.Value = "" Then Exit Sub
   If Not Intersect(Target, Range("Q:Q")) Is Nothing Then
      Me.Unprotect
      If MsgBox("is this entry correct? this cell cant be edited after once entered", vbYesNo, "cell Lock Notification") = vbYes Then
         Target.Locked = True
      End If
      Me.Protect
   End If
End Sub

wow
it works
i have been trying solving for this code from a long time .
but i couldn't do that perfectly
...
u r genius
hats off to you
thank you so much
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,656
Members
449,045
Latest member
Marcus05

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top