View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
William[_2_] William[_2_] is offline
external usenet poster
 
Posts: 227
Default Can't Seem to find problem with this VBA Code

Hi Kevin

The reason for the error when you enter data in Column A is because you are
testing.........
".....Target.Offset(0, -2).Value 1...."
the range A2.Offset(0,-2) does not exist.

Start your code with something like.....
If Target.Column < 6 Then Exit Sub

--

XL2003
Regards

William



"Kevin Baker" wrote in message
news:zKdee.671$It1.211@lakeread02...
If Target.Column = 6 And Target.Value 1 And Target.Offset(0, 2).Value
1 Then
Target.Offset(0, 3).Value = Target.Value - Target.Offset(0,
2).Value
ElseIf Target.Column = 8 And Target.Value 1 And
Target.Offset(0, -2).Value 1 Then
Target.Offset(0, 1).Value = Target.Offset(0, -2).Value - Target.Value
End If

I get the following when entering data in Cell A on a new line:
"Run-Time error '1004'
Application-defined or object-defined error

Any thoughts?
Kevin