+ Reply to Thread
Results 1 to 5 of 5

Dates in vba code

  1. #1
    Registered User
    Join Date
    01-04-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    13

    Dates in vba code

    Hi All

    I am trying to write a code for a cell on sheet 1 where the user inputs the value of date and in the next column or in the next sheet it should 6 months less 1 day. for example if user enters 01/01/2012 the result should be 30/06/2012 instead of exactly 01/07/2012 . I have tried the code below. The below code works for me to show exactly 6 months. But when i use "d" Instead of "m" some times the date values are incorrect. I Think thats because some have 30 days and others have 31 days. how to correct the code below so that it gives always 1 day less than 6months.

    Many thanx


    Please Login or Register  to view this content.
    Last edited by grk_chakri; 02-19-2012 at 02:08 PM.

  2. #2
    Registered User
    Join Date
    01-24-2012
    Location
    Swindon, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Dates in vba code

    Hi
    There would seem to be a logic problem in what you are trying to do. If you add 6 months to 31 August you get a date that does not exist. I think you need to define your logic so that it works for all dates and then you can write the code to implement the logic.

  3. #3
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Dates in vba code

    Please Login or Register  to view this content.
    may suffice for your purposes.
    Good luck.

  4. #4
    Registered User
    Join Date
    01-04-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Dates in vba code

    Such a foolish mistake it was, Any ways thanx a ton my dear friend,

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Dates in vba code

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1