Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Array formula and date value

Hi there.

I have an array formula (Sum(IF((...)) that I would like to include a date
value in. For example, Sum(If(($C$1:C$1000=1/3/2005),$B$1:$B$1000,0)).

For some reason that I can't figure out, it seems to work when I do this
directly in the worksheet but will not work when I try to create the formula
in VBA.

Is there some special way of handling a date value?

Thanks,
CaroKannDefence
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Array formula and date value

this works for me when I array enter it:
=SUM(IF(($C$1:C$1000=DATEVALUE("1/3/2005")),$B$1:$B$1000,0))

but your formula doesn't

Also, it would be easier to use sumif which will work like you have and
doesn't require to be array entered

=Sumif($C$1:C$1000,"1/3/2005",$B$1:$B$1000)

creating the formula in VBA is not clear.

Are you trying to get the sum in VBA or are you trying to write the formula
itself to a cell in VBA?


ActiveCell.Formula =
"=SUM(IF(($C$1:C$1000=DATEVALUE(""1/3/2005"")),$B$1:$B$1000,0))"

or
ActiveCell.Formula = "=Sumif($C$1:C$1000,""1/3/2005"",$B$1:$B$1000)"

or for the sum only:

ActiveCell.Formula = Application.Sumif(Range("$C$1:C$1000"), _
"1/3/2005",Range("$B$1:$B$1000"))

--
Regards,
Tom Ogilvy


.. "Caro-Kann Defence" wrote in
message ...
Hi there.

I have an array formula (Sum(IF((...)) that I would like to include a date
value in. For example, Sum(If(($C$1:C$1000=1/3/2005),$B$1:$B$1000,0)).

For some reason that I can't figure out, it seems to work when I do this
directly in the worksheet but will not work when I try to create the

formula
in VBA.

Is there some special way of handling a date value?

Thanks,
CaroKannDefence



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Array formula and date value

Tom.

Thanks for the reply. Your formula in the second line seems to have done
the trick! I think I may not have been including the quotation marks
properly.


"Tom Ogilvy" wrote:

this works for me when I array enter it:
=SUM(IF(($C$1:C$1000=DATEVALUE("1/3/2005")),$B$1:$B$1000,0))

but your formula doesn't

Also, it would be easier to use sumif which will work like you have and
doesn't require to be array entered

=Sumif($C$1:C$1000,"1/3/2005",$B$1:$B$1000)

creating the formula in VBA is not clear.

Are you trying to get the sum in VBA or are you trying to write the formula
itself to a cell in VBA?


ActiveCell.Formula =
"=SUM(IF(($C$1:C$1000=DATEVALUE(""1/3/2005"")),$B$1:$B$1000,0))"

or
ActiveCell.Formula = "=Sumif($C$1:C$1000,""1/3/2005"",$B$1:$B$1000)"

or for the sum only:

ActiveCell.Formula = Application.Sumif(Range("$C$1:C$1000"), _
"1/3/2005",Range("$B$1:$B$1000"))

--
Regards,
Tom Ogilvy


.. "Caro-Kann Defence" wrote in
message ...
Hi there.

I have an array formula (Sum(IF((...)) that I would like to include a date
value in. For example, Sum(If(($C$1:C$1000=1/3/2005),$B$1:$B$1000,0)).

For some reason that I can't figure out, it seems to work when I do this
directly in the worksheet but will not work when I try to create the

formula
in VBA.

Is there some special way of handling a date value?

Thanks,
CaroKannDefence




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
Array formula to find date Amylou Excel Worksheet Functions 0 March 25th 10 04:17 PM
date range table array formula [email protected] Excel Worksheet Functions 5 February 14th 09 03:31 AM
Conditional date array formula caj Excel Discussion (Misc queries) 1 September 23rd 06 06:42 AM
Conditional Array Formula for date caj Excel Discussion (Misc queries) 5 September 19th 06 09:05 PM
array formula: return next date from list [email protected] Excel Worksheet Functions 2 July 19th 06 10:15 PM


All times are GMT +1. The time now is 01:12 PM.

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

About Us

"It's about Microsoft Excel"