ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Auto delete cell content (https://www.excelbanter.com/excel-discussion-misc-queries/134580-auto-delete-cell-content.html)

[email protected]

Auto delete cell content
 
HI
I have a worksheet wherein at cell C8 i have put a validation as
follows
in case the value at B8 is more than zero then only any value in the
cell C8 can be fed.

The same is working , however in case i change the value at cell B8
from any number to zero the values at cell C8 does not get deleted.

does any body knows how to tackle this


Dave Peterson

Auto delete cell content
 
Data|Validation isn't retroactive--if you change the rules, then the existing
value isn't validated.

And if you want to actually clear the second cell, you're going to have to use a
macro--maybe an event macro like this:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myCell As Range
Set myCell = Me.Range("a1")
If Intersect(Target, myCell) Is Nothing Then Exit Sub

If IsEmpty(myCell.Value) Then
Application.EnableEvents = False
me.range("B1").Value = ""
Application.EnableEvents = True
End If

End Sub

If you want to try, I had my parent cell as A1 and my child as B1.

Rightclick on the worksheet tab that should have this behavior. Select view
code and paste this in (adjust those addresses). Then back to excel.

wrote:

HI
I have a worksheet wherein at cell C8 i have put a validation as
follows
in case the value at B8 is more than zero then only any value in the
cell C8 can be fed.

The same is working , however in case i change the value at cell B8
from any number to zero the values at cell C8 does not get deleted.

does any body knows how to tackle this


--

Dave Peterson


All times are GMT +1. The time now is 01:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com