Find last date of a month, given only year and month

girapas

Board Regular
Joined
Apr 20, 2004
Messages
150
In Sheet1 I enter a year and a month. Sheet2 is a database. Column A of Sheet2 filled with working dates. Among other things, I want to find the last date of the year's month entered in Sheet1, and get the cell value addressed of the column G and the same row with that last date.
Thanks in advance
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
In Sheet1 I enter a year and a month. Sheet2 is a database. Column A of Sheet2 filled with working dates. Among other things, I want to find the last date of the year's month entered in Sheet1, and get the cell value addressed of the column G and the same row with that last date.
Thanks in advance

Can you please post a sample of your data, and exactly how you enter the year and month? There are different approaches to this, based primarily on how the year/month is entered.
 
Upvote 0
Here is a sample. In sheet2 I've put only one month.

b></b>
Book1
AB
1enter year2012
2enter month1
3
4last day of month entered in B2, of year entered in B1?
5Total value (col G) of the last day of this month found?
6
Sheet1



Book1
ABCDEFG
1A B C D E
2dateAAABBBCCCDDDEEETotal
32/1/20128699976433379
43/1/20121881647699338
54/1/20122261272669205
65/1/20125318522133177
79/1/20124475865556316
810/1/20124027366947219
911/1/20122964951680284
1012/1/20124382241949217
1113/1/20126637577564299
1216/1/20128572532977316
1317/1/20124278243518197
1418/1/20126675133320207
1519/1/20126126977347304
1620/1/20126511787225251
1723/1/20127254914940306
1824/1/20123590866977357
1925/1/20126320722130206
2026/1/20127041352017183
2127/1/20126069707868345
2230/1/20129477997642388
2331/1/20121881697183322
24etc.etc.etc.etc.etc.etc.etc.
25
Sheet2
 
Upvote 0
Here is a sample. In sheet2 I've put only one month.

b></STRONG>
A
B

<TBODY>
[TD="align: center"]1
[/TD]
[TD="align: center"]enter year
[/TD]
[TD="align: center"]2012
[/TD]

[TD="align: center"]2
[/TD]
[TD="align: center"]enter month
[/TD]
[TD="align: center"]1
[/TD]

[TD="align: center"]3
[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]4
[/TD]
[TD="align: center"]last day of month entered in B2, of year entered in B1
[/TD]
[TD="align: center"]?
[/TD]

[TD="align: center"]5
[/TD]
[TD="align: center"]Total value (col G) of the last day of this month found
[/TD]
[TD="align: center"]?
[/TD]

[TD="align: center"]6
[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

</TBODY>
Sheet1

For the last day of the month, use this formula...

=DATE(B1,B2+1,0)
 
Upvote 0
And this formula should get you the Column G value for that date from the chart on Sheet1...

=LOOKUP(B4,Sheet1!A:A,Sheet1!G:G)
 
Upvote 0
Thank you, it's so simple! But I'm afraid I wasn't clear about it. The dates in Sheet2 are working days. So the actual last day of a month doesn't always is the same with the working day calculated.
 
Upvote 0
Thank you, it's so simple! But I'm afraid I wasn't clear about it. The dates in Sheet2 are working days. So the actual last day of a month doesn't always is the same with the working day calculated.
Okay, the try this formula...

=WORKDAY(DATE(B1,B2+1,1),-1)
 
Upvote 0
Thank you, it's so simple! But I'm afraid I wasn't clear about it. The dates in Sheet2 are working days. So the actual last day of a month doesn't always is the same with the working day calculated.

B4:

Either...

=WORKDAY(DATE(B1,B2+1,1),-1)

Or...

=DATE(B1,B2+1,1)-1

B5:

=VLOOKUP(B4,Sheet2!$A$2:$G$22,7,0)

Does the foregoing work for you?
 
Upvote 0
Great! Thank you. I hope I'm not be demanding, but there's yet a slight problem. I've named public and local holidays as Holidays2012, Holidays2013 etc. to calculate the working dates. Is there any way to include that dates in the formula you gave me?
 
Upvote 0
Great! Thank you. I hope I'm not be demanding, but there's yet a slight problem. I've named public and local holidays as Holidays2012, Holidays2013 etc. to calculate the working dates. Is there any way to include that dates in the formula you gave me?
Assuming you mean Holidays2012, Holidays2013, etc. are Defined Names for ranges containing dates for the holidays for those years, you can use this modification to the formula and it will adjust automatically for the correct year (taking it from B1) so long as you have a Defined Name for your holidays for each you plan to use his worksheet...

=WORKDAY(DATE(B1,B2+1,1),-1,INDIRECT("Holidays"&B1))
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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