Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I already have some other code in Worksheet_Change. Do I just add your code
under my current code, which is: If Target.Address = "$B$5" Then Application.EnableEvents = False Range("C16").Value = Null Range("E16").Value = Null Range("C5").Value = Null Application.EnableEvents = True End If Thanks - "Tom Ogilvy" wrote: whoops, Hit send too soon: Private Sub Worksheet_Change(ByVal Target As Range) Dim v As Variant If Target.Count 1 Then Exit Sub On Error GoTo ErrHandler If Target.Address = "$E$5" Then Application.EnableEvents = False v = Target.Value Application.Undo If Target.Value = 0 Then Application.EnableEvents = True Exit Sub If Target.Value 5 Then Target.Value = v Else Application.EnableEvents = True Exit Sub End If End If ErrHandler: Application.EnableEvents = True End Sub It could be more compact, but you should get the idea. -- Regards, Tom Ogilvy "Alex" wrote: Can someone help me write the following code to say the following? If someone is trying to change the value of cell E5 and the current content of cell E5 is 0 then the contents cannot be change. But, if they are trying to change the value of cell E5 and the current content of cell E5 is 0 then they can change it to 0. Thanks very much. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
need help creating a Worksheet_Change code | Excel Worksheet Functions | |||
inserting code into a Worksheet_Change event | Excel Programming | |||
Temporarily Suspending Worksheet_Change() until other code is run. | Excel Programming | |||
disappearing worksheet_change VBA code - help! | Excel Programming | |||
Worksheet_Change even code will not run | Excel Programming |