And if you go the formula way, try this

=IF(DAY(A2)=1,DATE(YEAR(A2-1)+60,MONTH(A2-1)+1,0),DATE(YEAR(A2)+60,MONTH(A2)+1,0))

On Mon, Sep 12, 2011 at 9:43 PM, Sam Mathai Chacko <samde...@gmail.com>wrote:

> Thought you wanted to increment date only...
>
> Try this
>
> Private Sub CommandButton1_Click()
>
>     txtdor.Text = DateAdd("yyyy", 60, IIf(Day(CDate(txtdob.Text)) = 1,
> DateAdd("d", -1, CDate(txtdob.Text)), DateAdd("m", 1,
> DateSerial(Year(CDate(txtdob.Text)), Month(CDate(txtdob.Text)), 1)) - 1))
>
> End Sub
>
> Sam Mathai Chacko (GL)
>
>
> On Mon, Sep 12, 2011 at 9:37 PM, Shankar Bheema <shankar.n...@gmail.com>wrote:
>
>> I tried with the provided code but its working only with the years but
>> months and days are not working
>>
>>
>> On Mon, Sep 12, 2011 at 9:33 PM, Sam Mathai Chacko <samde...@gmail.com>wrote:
>>
>>> Private Sub CommandButton1_Click()
>>>
>>>     txtdor.Text = DateAdd("yyyy", 60, IIf(Day(CDate(txtdob.Text)) = 1,
>>> DateAdd("d", -1, CDate(txtdob.Text)), CDate(txtdob.Text)))
>>>
>>> End Sub
>>>
>>> Regards,
>>>
>>> Sam Mathai Chacko (GL)
>>>
>>>
>>> On Mon, Sep 12, 2011 at 9:28 PM, Shankar Bheema 
>>> <shankar.n...@gmail.com>wrote:
>>>
>>>> but i am using userform na sir. So pls see my attachment and i am not
>>>> understanding the mistake i did in my code
>>>>
>>>>
>>>> On Mon, Sep 12, 2011 at 9:07 PM, dguillett1 <dguille...@gmail.com>wrote:
>>>>
>>>>>      Why not just a simple formula for a dob in cell d11
>>>>>
>>>>> =DATE(YEAR(D11)+60,MONTH(D11)+1,0)
>>>>>
>>>>>  *From:* Shankar Bheema <shankar.n...@gmail.com>
>>>>> *Sent:* Monday, September 12, 2011 9:54 AM
>>>>> *To:* excel-macros@googlegroups.com
>>>>> *Subject:* $$Excel-Macros$$ date difference
>>>>>
>>>>> Hai all,
>>>>>
>>>>> I am attaching an excel userform which contains Dateof Birth textbox
>>>>> and Date of Retirement textbox.
>>>>>
>>>>> Conditions are:
>>>>>
>>>>> i) Date of Retirement should be 60 years after Date of Birth
>>>>> eg. if date of birth is in the year 1960 date of retirement would be
>>>>> 2020
>>>>>
>>>>> ii) Date of retirement would be last  day of the month
>>>>>
>>>>> if date of birth is on 28-04-1981 then date of retirement would in the
>>>>> last day of the April month i.e. 30-04-2041
>>>>>
>>>>> iii) if the date of retirement falls in the month of February and if it
>>>>> is a leap year then the retirement date would be 29th feb.
>>>>>
>>>>> iv) If date of birth fells on 1st of the month the retirement date
>>>>> would be the last day of the last month
>>>>> eg. if Dob is 01-01-2012 then the date of retirement would be
>>>>> 31-12-2011.
>>>>>
>>>>> I have written code for that but its not throwing errors.  if there is
>>>>> any simplest way may kindly be suggest.
>>>>> --
>>>>>
>>>>> ----------------------------------------------------------------------------------
>>>>> Some important links for excel users:
>>>>> 1. Follow us on TWITTER for tips tricks and links :
>>>>> http://twitter.com/exceldailytip
>>>>> 2. Join our LinkedIN group @
>>>>> http://www.linkedin.com/groups?gid=1871310
>>>>> 3. Excel tutorials at http://www.excel-macros.blogspot.com
>>>>> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
>>>>> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>>>>>
>>>>> To post to this group, send email to excel-macros@googlegroups.com
>>>>>
>>>>> <><><><><><><><><><><><><><><><><><><><><><>
>>>>> Like our page on facebook , Just follow below link
>>>>> http://www.facebook.com/discussexcel
>>>>>
>>>>> --
>>>>>
>>>>> ----------------------------------------------------------------------------------
>>>>> Some important links for excel users:
>>>>> 1. Follow us on TWITTER for tips tricks and links :
>>>>> http://twitter.com/exceldailytip
>>>>> 2. Join our LinkedIN group @
>>>>> http://www.linkedin.com/groups?gid=1871310
>>>>> 3. Excel tutorials at http://www.excel-macros.blogspot.com
>>>>> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
>>>>> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>>>>>
>>>>> To post to this group, send email to excel-macros@googlegroups.com
>>>>>
>>>>> <><><><><><><><><><><><><><><><><><><><><><>
>>>>> Like our page on facebook , Just follow below link
>>>>> http://www.facebook.com/discussexcel
>>>>>
>>>>
>>>>  --
>>>>
>>>> ----------------------------------------------------------------------------------
>>>> Some important links for excel users:
>>>> 1. Follow us on TWITTER for tips tricks and links :
>>>> http://twitter.com/exceldailytip
>>>> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
>>>> 3. Excel tutorials at http://www.excel-macros.blogspot.com
>>>> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
>>>> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>>>>
>>>> To post to this group, send email to excel-macros@googlegroups.com
>>>>
>>>> <><><><><><><><><><><><><><><><><><><><><><>
>>>> Like our page on facebook , Just follow below link
>>>> http://www.facebook.com/discussexcel
>>>>
>>>
>>>
>>>
>>> --
>>> Sam Mathai Chacko
>>>
>>>  --
>>>
>>> ----------------------------------------------------------------------------------
>>> Some important links for excel users:
>>> 1. Follow us on TWITTER for tips tricks and links :
>>> http://twitter.com/exceldailytip
>>> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
>>> 3. Excel tutorials at http://www.excel-macros.blogspot.com
>>> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
>>> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>>>
>>> To post to this group, send email to excel-macros@googlegroups.com
>>>
>>> <><><><><><><><><><><><><><><><><><><><><><>
>>> Like our page on facebook , Just follow below link
>>> http://www.facebook.com/discussexcel
>>>
>>
>>  --
>>
>> ----------------------------------------------------------------------------------
>> Some important links for excel users:
>> 1. Follow us on TWITTER for tips tricks and links :
>> http://twitter.com/exceldailytip
>> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
>> 3. Excel tutorials at http://www.excel-macros.blogspot.com
>> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
>> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>>
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>> <><><><><><><><><><><><><><><><><><><><><><>
>> Like our page on facebook , Just follow below link
>> http://www.facebook.com/discussexcel
>>
>
>
>
> --
> Sam Mathai Chacko
>



-- 
Sam Mathai Chacko

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to