• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Dates Count

Shailender

Member
Hello, need a help on the dates, Let's assume I am working on a dates for fiscal year so my start date is 10/31/2016 and my end date is 3/31/2017 like that it goes on till 9/30/2017.

Please refer to Sheet1, So here my start date starts from A1 and end date ends at F1 at present, and for next month the end date would be G1, like wise it will goes on until I reach to 9/30/2017.
So what I want exactly is A1 should count as month one and F1 should be count as 6, next month G1 should be counted as 7.

So I have written a code when I execute it the month count shows number 3 wherein it suppose to show the count 6. Please refer to the Sheet1 G2 cell, my end result should be like that.

Please help me out on this thank you in advance!
 

Attachments

  • Dates1.xlsm
    16.9 KB · Views: 3
Hello Marc L, thank you for the prompt response, When i execute the code it is throwing an error message. I tried with 2 different types,
1) As mentioned above 2) I declared Dim Crmonth as Integer and then given the following code "Crmonth = DateDiff("m", [StrColm], [EndColm]) + 1", but in both cases it is showing an error message TypeMismatch.

For your reference i am attaching the excel sheet. Thank you!
 

Attachments

  • Dates1.xlsm
    17.5 KB · Views: 1
as Marc L wrote MsgBox DateDiff("M", [A1], [F1]) + 1
check those variables StrColm & EndColm (those are "A1" & "F1")
but You could use next:
MsgBox DateDiff("M", Range(StrColm), Range(EndColm)) + 1
 
Back
Top