Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 14th, 2007, 08:39 PM
Authorized User
Join Date: Mar 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default month comparison,update status to 'Due Soon'

    Pls kindly help.. i need to write the formula using vb, such as if the data's date is within next 3 months, i need to set the status of the action item to 'Due soon'.
Eg) Today is in the month of may, so any dates in the data from May->July should have a status set to 'Due Soon'..


Old May 14th, 2007, 11:33 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts

Here you have miracles

Sub Check_Date_Within_3_Months()

Dim CurrentDate As Date
Dim ThirdMonthDate As Date
Dim D1Date As Date

On Error Resume Next

CurrentDate = Now
ThirdMonthDate = DateAdd("m", 3, CurrentDate)
D1Date = "2007/06/15"

If DateDiff("d", CurrentDate, D1Date) > 0 And DateDiff("d", ThirdMonthDate, D1Date) < 0 Then
    MsgBox "Date is within the period"
    'Set action to Due Soon
    MsgBox "Date is outside the period"
End If

End Sub



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting month name to month number kalyanykk SQL Server 2005 7 August 19th, 2008 10:37 PM
Need date comparison and month from same db field scottiegirl PHP Databases 13 December 1st, 2007 12:43 PM
Text Box too wide due to value? Ron Howerton HTML Code Clinic 0 May 7th, 2007 01:34 PM
query Current Month, Month+1, Month+2, Month+3 anterior Access 2 September 24th, 2006 08:25 PM
Might this be a logic error due to the code? Ben Horne Javascript 1 November 30th, 2004 08:59 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.