Date comparison in excell

bennie46

New Member
Joined
Feb 10, 2016
Messages
2
I have a table that has 14 tabs. One for each of the months and 2 summary pages. On each of the months tabs I have data in cells G9:G18. On one of the summary pages I am trying to pull said data into it from the 12 months tabs, but only want the previous months and the current months data. In cell A1 of the summary tab I have the today function in place (=TODAY()) I am using cell A1 as a reference cell. I am trying to use embedded if statements to step through each month to determine if today's date is less then the last day of each month to determine what data is pulled. Below is an example of the formula that I am trying to use. The Date in cell A1 is 2/10/2016. I have tried this formula as it is shown, without the double quotes around the date, with single quotes around the date, used the DATE(,,) function, tried it with an & in front of the date and this formula always seems to return the information from the January tab. Please help

=IF(A1<="1/31/2016",January!G9,(IF(A1<="2/29/2016",February!G9,(IF(A1<="3/31/2016",March!G9,(IF(A1<="4/30/2016",April!G9,(IF(A1<="5/31/2016",May!G9,(IF(A1<="6/30/2016",June!G9,(IF(A1<="7/31/2016",July!G9,(IF(A1<="8/31/2016",August!G9,(IF(A1<="9/30/2016",September!G9,(IF(A1<="10/30/2016",October!G9,(IF(A1<="11/31/2016",November!G9,(IF(A1<=12/31/2016,December!G9,"")))))))))))))))))))))))
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Since you're using nested if statements, the first time it evaluates as true, you're fed that data. You need a macro that will use looping logic to return data for all the months you are interested in. You can then use that macro as a formula which would be MUCH easier to maintain.

Do you have a sample of what you want the output data to look like? Dummy data would be fine, I'm just trying to figure out what you are trying to do.
 
Upvote 0
Since you're using nested if statements, the first time it evaluates as true, you're fed that data. You need a macro that will use looping logic to return data for all the months you are interested in. You can then use that macro as a formula which would be MUCH easier to maintain.

Do you have a sample of what you want the output data to look like? Dummy data would be fine, I'm just trying to figure out what you are trying to do.

OK each of the months tabs contain the following data:

Total Samples7
Total Collections4
Total Not Collected3
Total Exceptions0
Todays Date:2/12/2016
Start Date:1/1/2016
End Date:1/31/2016
Average per Day:0.3
Job Status:On Track

<colgroup><col span="2"></colgroup><tbody>
</tbody>


The data varies depending on what month it is pulled from and what the date currently is as it is a spreadsheet that gets updated on a daily basis. What I am trying to do as stated before is use the formula that I previously posted to pull this data from the current months tab and the previous months tab based on the current date. I am doing this to be able to automate some reporting. I have been able to get the nested if function to work in the past just not with dates. What I am trying to figure out is if there is something that I need to do differently with the if statement and the dates to make them work. It usually pulls only the month of January, or December never in between. So it seems like the date is not being recognized for some reason.
 
Upvote 0

Forum statistics

Threads
1,215,018
Messages
6,122,703
Members
449,093
Latest member
Mnur

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