Array Forumla Help

Paul75

New Member
Joined
Apr 27, 2011
Messages
6
Hi,
I'm a reasonably basic user so looking for some help with a formula please.

I have 2 columns. Column 'A' has dates, column 'B' has numbers. What I'm trying to achieve is that when the user enters 2011 on a different worksheet then it will sum all the numbers in column 'B' where the corresponding date has the year 2011. This I have achieved with the following formula;
{=IF(ISBLANK($A1),"",SUM(IF(YEAR(FlightDates)=$A1,Hours_Total_Flight)))} where 'FlightDates' is column A and Hours_Total_Flight is column B.

What I can't seem to do is to sum column B for a certain year and a certain month ie, the user has selected 2011 and 4. I would want all the flight hours from April 2011 to be summed.

Not sure if that makes too much sense. Hopefully does.
Looking forward to any feedback or help.

Regards,
Paul.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You could use SUMPRODUCT and avoid "array entering", e.g. if month number is entered in B1 try

=IF(COUNT($A1,$B1)=2,SUMPRODUCT((YEAR(FlightDates)=$A1)*(MONTH(FlightDates)=$B1),Hours_Total_Flight),"")
 
Upvote 0
Hi,
I'm a reasonably basic user so looking for some help with a formula please.

I have 2 columns. Column 'A' has dates, column 'B' has numbers. What I'm trying to achieve is that when the user enters 2011 on a different worksheet then it will sum all the numbers in column 'B' where the corresponding date has the year 2011. This I have achieved with the following formula;
{=IF(ISBLANK($A1),"",SUM(IF(YEAR(FlightDates)=$A1,Hours_Total_Flight)))} where 'FlightDates' is column A and Hours_Total_Flight is column B.

What I can't seem to do is to sum column B for a certain year and a certain month ie, the user has selected 2011 and 4. I would want all the flight hours from April 2011 to be summed.

Not sure if that makes too much sense. Hopefully does.
Looking forward to any feedback or help.

Regards,
Paul.
Control+shift+enter, not just enter:

=IF(OR($A1="",$B1=""),"",SUM(IF(YEAR(FlightDates)=$A1,IF(MONTH(FlightDates)=$B1,Hours_Total_Flight))),"")

where B1 houses a month number of interest.
 
Upvote 0
Thanks heaps Barry and Aladin.

Work perfectly thanks Aladin, I was missing an IF.

Your help is very much appreciated.
 
Upvote 0
Sorry one more question Aladin.

That formula works if I enter a month and a year, it will sum all the hours in say Apr 2011. How do I make it that if the month field is left blank but 2011 is still entered all the hours from 2011 are still summed.
At the moment if I leave the month field empty but still have a year it returns 0.0.

Regards.
 
Upvote 0
Hi Paul

Try:

=IF($A1="","",SUM(IF(YEAR(FlightDates)=$A1,IF((MONTH(FlightDates)=$B1)+($B1=""),Hours_Total_Flight))))
 
Upvote 0
Hi Paul

Try:

=IF($A1="","",SUM(IF(YEAR(FlightDates)=$A1,IF((MONTH(FlightDates)=$B1)+($B1=""),Hours_Total_Flight))))

Perhaps the initial a bit modified...

=IF($A1&$B1="","",SUM(IF(YEAR(FlightDates)=$A1,IF((MONTH(FlightDates)=$B1)+($B1=""),Hours_Total_Flight))))
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top