Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
RGB
 
Posts: n/a
Default Month & year question

hello,

I have the following formula which works fine;

=IF(AND(L$1=data!$K2, L$1<=data!$H2),
(IF(MONTH(L$1)=MONTH(data!$K2),$F2,data!$I2/data!$G2)),"")

I need to change it so that the bit (IF(MONTH(L$1)=MONTH(data!$K2) checks
that a date matches not only the month but the year also (i dont need to
match the day).

I tried this; - but excel says that it contains an error!

=IF(AND(L$1=data!$K2, L$1<=data!$H2), (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)),$F2,data!$I2/data!$G2)),"")

Any ideas how I can correct (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)) to work?

many thanks

rgb

  #2   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Month & year question

Hi

You'll need an AND in there. Try this:
=IF(AND(L$1=data!$K2, L$1<=data!$H2),
(IF(AND(MONTH(L$1)=MONTH(data!$K2),YEAR(L$1)=YEAR( data!$K2)),$F2,data!$I2/data!$G2)),"")
untested.

Andy.

"RGB" wrote in message
...
hello,

I have the following formula which works fine;

=IF(AND(L$1=data!$K2, L$1<=data!$H2),
(IF(MONTH(L$1)=MONTH(data!$K2),$F2,data!$I2/data!$G2)),"")

I need to change it so that the bit (IF(MONTH(L$1)=MONTH(data!$K2) checks
that a date matches not only the month but the year also (i dont need to
match the day).

I tried this; - but excel says that it contains an error!

=IF(AND(L$1=data!$K2, L$1<=data!$H2), (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)),$F2,data!$I2/data!$G2)),"")

Any ideas how I can correct (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)) to work?

many thanks

rgb



  #3   Report Post  
Posted to microsoft.public.excel.misc
Miguel Zapico
 
Posts: n/a
Default Month & year question

You may use the AND function there, as you did before
=IF(AND(L$1=data!$K2, L$1<=data!$H2),
IF(AND(MONTH(L$1)=MONTH(data!$K2),YEAR(L$1)=YEAR(d ata!$K2)),$F2,data!$I2/data!$G2),"")

Hope this helps,
Miguel.

"RGB" wrote:

hello,

I have the following formula which works fine;

=IF(AND(L$1=data!$K2, L$1<=data!$H2),
(IF(MONTH(L$1)=MONTH(data!$K2),$F2,data!$I2/data!$G2)),"")

I need to change it so that the bit (IF(MONTH(L$1)=MONTH(data!$K2) checks
that a date matches not only the month but the year also (i dont need to
match the day).

I tried this; - but excel says that it contains an error!

=IF(AND(L$1=data!$K2, L$1<=data!$H2), (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)),$F2,data!$I2/data!$G2)),"")

Any ideas how I can correct (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)) to work?

many thanks

rgb

  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Month & year question

=IF(AND(L$1=data!$K2, L$1<=data!$H2),
(IF(TEXT(L$1,"yyyymm")=TEXT(data!$K2,"yyyymm"),$F2 ,data!$I2/data!$G2)),"")

--
HTH

Bob Phillips

(replace xxxx in email address with googlemail if mailing direct)

"RGB" wrote in message
...
hello,

I have the following formula which works fine;

=IF(AND(L$1=data!$K2, L$1<=data!$H2),
(IF(MONTH(L$1)=MONTH(data!$K2),$F2,data!$I2/data!$G2)),"")

I need to change it so that the bit (IF(MONTH(L$1)=MONTH(data!$K2) checks
that a date matches not only the month but the year also (i dont need to
match the day).

I tried this; - but excel says that it contains an error!

=IF(AND(L$1=data!$K2, L$1<=data!$H2), (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)),$F2,data!$I2/data!$G2)),"")

Any ideas how I can correct (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)) to work?

many thanks

rgb



  #5   Report Post  
Posted to microsoft.public.excel.misc
RGB
 
Posts: n/a
Default Month & year question

Many thanks Miguel,

The formula still seems to have to exactly match the day part of $K2 to pull
through $F2 however. I need to match the year and month parts of $K2 only.

Cheers

RGB


"Miguel Zapico" wrote:

You may use the AND function there, as you did before
=IF(AND(L$1=data!$K2, L$1<=data!$H2),
IF(AND(MONTH(L$1)=MONTH(data!$K2),YEAR(L$1)=YEAR(d ata!$K2)),$F2,data!$I2/data!$G2),"")

Hope this helps,
Miguel.

"RGB" wrote:

hello,

I have the following formula which works fine;

=IF(AND(L$1=data!$K2, L$1<=data!$H2),
(IF(MONTH(L$1)=MONTH(data!$K2),$F2,data!$I2/data!$G2)),"")

I need to change it so that the bit (IF(MONTH(L$1)=MONTH(data!$K2) checks
that a date matches not only the month but the year also (i dont need to
match the day).

I tried this; - but excel says that it contains an error!

=IF(AND(L$1=data!$K2, L$1<=data!$H2), (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)),$F2,data!$I2/data!$G2)),"")

Any ideas how I can correct (IF(MONTH(L$1),(YEAR
(L$1))=(MONTH(data!$K2)),(YEAR (L$1)) to work?

many thanks

rgb

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
how to insert month date year and day of week Sachi Noma New Users to Excel 2 May 19th 06 03:03 AM
how to insert month date year and day of week Sachi Noma Excel Worksheet Functions 3 May 19th 06 03:03 AM
Locate month and year from range of date from another sheet Rao Ratan Singh New Users to Excel 3 March 1st 06 07:55 AM
Excel leap year question Jason New Users to Excel 4 December 3rd 05 09:01 PM
counting date entries by month & year Di Excel Worksheet Functions 7 August 24th 05 08:39 PM


All times are GMT +1. The time now is 01:54 AM.

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"