Trouble entering formula into cell

L

Luke

I wrote a macro to reformat a report. As it goes from row to row rearranging
the data from the report, there are some cells where I need the code to enter
a formula into the cell. However, when it hits that part I keep getting
error 1004 - application or user-defined error. Here is the portion of the
code that gives me fits:

Range("H" & Count + 2).Value = Range("F" & Count + 6).Value
Range("I" & Count + 2).Value = ""
Range("J" & Count + 2).Formula = "=IF(I" & Count + 2 &
"=""00/00/0000"",0,IF(I" & Count + 2 & "-H" & Count + 2 & _
">1,1,0)"

I get the error when it hits the 'Range("J"' line. For referrence, the
value placed into column H is a date and Count is Dim'd as Long. I'm not
worried that the result of the formula (that I'm trying to put in column J)
will give an error, I just want the formula there. I've even tried changing
the code so that it always puts "00/00/0000" in column I, but it didn't work.
 
R

Ryan H

You needed to add a ")" at the end.

Range("J" & Count + 2).Formula = "=IF(I" & Count + 2 &
"=""00/00/0000"",0,IF(I" & Count + 2 & "-H" & Count + 2 & ">1,1,0))"

Hope this helps! If so, let me know, click 'YES" below.
 
L

Luke

Sheesh. I tied my brain in knots trying to figure out what I did wrong, even
meticulously pouring over the quotes just to make sure I got them right.
Never even began to suspect I left out a parenthesis at the end. It's always
the little things that get you.

Thanks for the extra pair of eyes.
 

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