Results 1 to 5 of 5

Dates in vba code

Threaded View

grk_chakri Dates in vba code 02-14-2012, 03:33 PM
Swindon Dominic Re: Dates in vba code 02-14-2012, 05:54 PM
OnErrorGoto0 Re: Dates in vba code 02-14-2012, 07:23 PM
grk_chakri Re: Dates in vba code 02-15-2012, 12:24 AM
royUK Re: Dates in vba code 02-15-2012, 01:23 AM
  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


     
    
    D28 = 01/01/2012
    
    If Range("D24").Value = "FIXED" Then
    
    Range("D29").Value = DateAdd("m", 6, Range("d28").Value)
    
    else
    
    Range("D29").Value = "XXXX"
    
    End If
    Last edited by grk_chakri; 02-19-2012 at 02:08 PM.

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