Run time error on formula

R

Richard

Can anyone please look at this formula and see why I'm
getting a run time error. I'm new and not quite sure if
I've written the wright procedure.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False
Worksheets("Sheet1").Range("G3").Formula = "=(IF(OR
(E3,F3>0),G2-E3+F3,""))"
Worksheets("Sheet1").Range("G3", Range("F65536").End
(xlUp).Offset(3, 7)).FillDown
Application.EnableEvents = True
End Sub
Thanks in advance!
 
B

Bob Umlas Excel MVP

The formula "=(IF(OR(E3,F3>0),G2-E3+F3,""))"
needs to be
"=(IF(OR(E3,F3>0),G2-E3+F3,""""))"
-- to represent a quote inside a literal string, you need
2 quotes.
Also, you don't need to say Worksheets("Sheet1") anywhere
because that's the worksheet inside the change event
anyway (hopefully!)

Range("G3").Formula = "=(IF(OR(E3,F3>0),G2-E3+F3,""""))"
and
Range("G3", Range("F65536").End(xlUp).Offset(3,
7)).FillDown
 
F

Frank Kabel

Hi
change the line
Worksheets("Sheet1").Range("G3").Formula = "=(IF(OR
(E3,F3>0),G2-E3+F3,""))"

to
Worksheets("Sheet1").Range("G3").Formula = "=(IF(OR
(E3,F3>0),G2-E3+F3,""""))"
 
R

Richard

Thanks! That fixed that problem but if i have more debts
in e3 than credits in f3 it stops counting. Any way to
keep the formula running down.
 
J

Juan Sanchez

Hi Richard,

Try modifying this part:

..Formula = "=(IF(OR(E3,F3>0),G2-E3+F3,""))"
..Formula = "=(IF(OR(E3,F3>0),G2-E3+F3,""""))"

That should do it...

Cheers
Juan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top