Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Trouble entering formula into cell

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Trouble entering formula into cell

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.

--
Cheers,
Ryan


"Luke" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Trouble entering formula into cell

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.

"Ryan H" wrote:

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.

--
Cheers,
Ryan


"Luke" wrote:

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Entering Formula - Cannot select cell as it is hidden by formula Jim Excel Worksheet Functions 0 March 25th 10 07:22 AM
Trouble Entering Old Date Formats JRTB New Users to Excel 2 July 24th 07 04:09 PM
trouble entering dates andresg1975 Excel Discussion (Misc queries) 5 November 6th 06 05:47 PM
Entering Sum formula into a cell Bernard Liengme[_3_] Excel Programming 0 September 29th 03 04:11 PM
Entering Sum formula into a cell Don Guillett[_4_] Excel Programming 0 September 29th 03 03:55 PM


All times are GMT +1. The time now is 03:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"