Debug problem
Sofia,
is this just a code snippet?
You use .Range() etc. but without a WITH...END WITH
Also, if you use
If NOT Intersect(Target, forside.Range("B6:B7")) Is Nothing then
' here goes your code
End if
End Sub
then you don't need the "Exit Sub" - and your sub has just one exit point...
Not sure why you get into debug mode if there is a zero in A1:D1 because
you don't tell us what's in D45 (must be a formula though)
Regards,
Dominik.
Sofia Grave schrieb:
in Range [A1:D1] I insert some data by hand, but sometimes the value is
zero.
the .Range("D45").GoalSeek goal:=0, changingcell:=.Range("D44") is based
on A1 value and so on for the other lines.
My question is, when in the range [A1:D1] the value is ZERO the code
stops for debug, how can I avoid this without open all the times the
debug window and coment the .ranges that corresponds to Zero value in
RANGE [A1:D1]?
That is something that I can put in the below code?
B6:B7 is what triggers the Goal seek command.
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, forside.Range("B6:B7")) Is Nothing Then
Exit Sub
Else
.Range("D45").GoalSeek goal:=0, changingcell:=.Range("D44")
'A1 value
.Range("f45").GoalSeek goal:=0, changingcell:=.Range("F44") 'B1
value
.Range("h45").GoalSeek goal:=0, changingcell:=.Range("H44")
'C1 value
.Range("J45").GoalSeek goal:=0, changingcell:=.Range("J44") 'D1
value
End If
End Sub
Could someone help me
|