Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Formula & Dates


Hi there,

Is it possible to set the number of rows in a range based on a start and end date?. I'm not sure even how to start this, but if say I has the start date in cell A1 and end date in cell B1, it is then possible to set how many rows will be programatically generated relating to number of month's between the two dates in any defined range. My first row would be made of a series of formula which I would like to be copied down to the end of the range, which would generate a set of figures.

Any help appreciated !

Thanks for your help

John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Formula & Dates

Hi John,

I'm not sure if this is what you're looking for, but here's a function that
will return the number of months between any 2 dates.

Public Function glGetNumberOfRows(dtStart As Date, _
dtEnd As Date) As Long
glGetNumberOfRows = DateDiff("m", dtStart, dtEnd)
End Function

You could call this function from code:

MsgBox glGetNumberOfRows(Sheet1.Range("A1").Value, _
Sheet1.Range("A2").Value)

Or from a worksheet:

=glGetNumberOfRows(A1, A2)

If you're going to use it from a worksheet, you could simply use the
built-in DATEDIF worksheet function (not documented in help in some
versions). You can learn more about it on Chip Pearson's site:

http://www.cpearson.com/excel/datedif.htm

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


John M wrote:
Hi there,

Is it possible to set the number of rows in a range based on a start
and end date?. I'm not sure even how to start this, but if say I has
the start date in cell A1 and end date in cell B1, it is then
possible to set how many rows will be programatically generated
relating to number of month's between the two dates in any defined
range. My first row would be made of a series of formula which I
would like to be copied down to the end of the range, which would
generate a set of figures.

Any help appreciated !

Thanks for your help

John


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need a formula that has to do with dates. Excel4dummies Excel Worksheet Functions 1 October 29th 09 12:49 AM
Formula for Dates KC Excel Discussion (Misc queries) 3 October 16th 09 11:51 PM
formula using dates bookish Excel Worksheet Functions 2 October 26th 07 02:30 PM
Formula With Dates Mike Excel Worksheet Functions 1 January 31st 06 03:13 AM
How Do I Add Dates in a formula? Rogue Excel Worksheet Functions 3 January 9th 06 07:12 AM


All times are GMT +1. The time now is 02:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"