ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calc Number of Months PER YEAR Between Dates (https://www.excelbanter.com/excel-programming/444761-calc-number-months-per-year-between-dates.html)

amywolfie[_2_]

Calc Number of Months PER YEAR Between Dates
 
Hi:

I have two dates:

2/3/2005

6/8/2007

I need to calculate the number of months PER YEAR between the dates.
For example:

YEAR # MONTHS/YR
2005 12
2006 12
2007 6

This can be VBA, a recorded macro, or a calc. Thanks!


Don Guillett[_2_]

Calc Number of Months PER YEAR Between Dates
 
On Jul 11, 5:34*pm, amywolfie wrote:
Hi:

I have two dates:

2/3/2005

6/8/2007

I need to calculate the number of months PER YEAR between the dates.
For example:

YEAR * *# MONTHS/YR
2005 * * 12
2006 * * 12
2007 * * *6

This can be VBA, a recorded macro, or a calc. *Thanks!


This UDF (placed in a REGULAR module) and then, on the sheet, type
=monthsinyear(a1,a2,2005)
or if b1 has 2005
=monthsinyear(a1,a2,b1)
to get 2005

amywolfie[_2_]

Calc Number of Months PER YEAR Between Dates
 
Thanks Don.

I have never written VBA code for Excel, only Access.

How do you define a REGULAR module?

Do you create a Public Function monthsinyear () where

Dim monthsinyear As Integer

Is there anything else that has to be coded in VBA?

Thanks!
====


All times are GMT +1. The time now is 03:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com