Exclude a range from "0"
Wouldn't you just test that range first
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myCell As Range
Dim myRng As Range
Set myRng = Me.Range("E10:AK24")
Application.EnableEvents = False
For Each myCell In Intersect(Target, myRng).Cells
If myCell.Value = "" Then
myCell.Value = 0
End If
If Not Intersect(myCell, Me.Range("E10:M24")) Is Nothing Then
myCell.Value = Abs(myCell.Value)
ElseIf Not Intersect(myCell, Me.Range("P10:P24")) Is Nothing Then
'do something in this case
ElseIf Not Intersect(myCell, Me.Range("Q10:AH24")) Is Nothing Then
myCell.Value = -Abs(myCell.Value)
End If
Next myCell
Application.EnableEvents = True
End Sub
--
---
HTH
Bob
(change the xxxx to gmail if mailing direct)
"Please help James" wrote in
message ...
Does anyone how to exlude a range from the code as outlined below. I need
to
have "P10:P24" show up as blank when a user hits the delete button.
Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myCell As Range
Dim myRng As Range
Set myRng = Me.Range("E10:AK24")
Application.EnableEvents = False
For Each myCell In Intersect(Target, myRng).Cells
If myCell.Value = "" Then
myCell.Value = 0
End If
If Not Intersect(myCell, Me.Range("E10:M24")) Is Nothing Then
myCell.Value = Abs(myCell.Value)
End If
If Not Intersect(myCell, Me.Range("Q10:AH24")) Is Nothing Then
myCell.Value = -Abs(myCell.Value)
End If
Next myCell
Application.EnableEvents = True
End Sub
|