View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default worksheet change

This didn't work:

if target.value < "" then .Undo



ram wrote:

Hi Jim

I have a syntax error in the following line of code

if target.value < '' then .Undo

I tried using double quotes and single quotes, neither corrected the error.

Do you have any suggestion on how I can correct this error?

Thanks for any help

"Jim Thomlinson" wrote:

Try this...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
with Application
.EnableEvents = False
if target.value < '' then .Undo
.EnableEvents = True
.Speech.Speak "Locked Cell"
end with
End If
End Sub

One thing to keep in mind is that this code will not execute if the user
pastes into this column...
--
HTH...

Jim Thomlinson


"ram" wrote:

I have the following code to protect cells in a shared workbook. What I'm
trying to do is tun off the undo if the cell is blank

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Application.Speech.Speak "Locked Cell"
End If
End Sub

Thanks for any help.

Thanks for all the help today


--

Dave Peterson