Calc Number of Months PER YEAR Between Dates

A

amywolfie

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!
 
D

Don Guillett

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
 
A

amywolfie

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!
====
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top