Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 16th, 2005, 03:33 PM
Authorized User
 
Join Date: Nov 2005
Location: Houston, TX, .
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via Yahoo to tonyrosen
Default New Problem

Which I don't think is anything other than I'm not versed in this stuff well enough ...

Let's say you have two dates (StartDate and StopDate)

'====================================
StartDate = Range("A3") 'assuming it's already a date
StopDate = Range("A4") 'assuming it's already a date
StopYear = Year(StartDate) + 1
AfterThisDate = "12/31/" & StopYear
'====================================

I need to check to see if the StopDate is less than the AfterThisDate ...

Basically:
If StopDate < AfterThisDate Then
     'Throw an error
End If

However, it's not calculating unless the dates are equal ... Am I missing something?

Reply With Quote
  #2 (permalink)  
Old November 17th, 2005, 03:54 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Bournemouth, Dorset, United Kingdom.
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Tony,

I just bundled this togther for you...

startdate = Range("A3")
stopdate = Range("A4")
stopyear = CDate(("31 December " & Year(startdate) + 1))
If IsDate(startdate) And IsDate(stopdate) And IsDate(stopyear) Then
    If stopdate > stopyear Then
        MsgBox ("Stopped")
    Else
        MsgBox ("OK")
    End If
Else
End If

cheers

Matt

Reply With Quote
  #3 (permalink)  
Old November 17th, 2005, 09:59 AM
Authorized User
 
Join Date: Nov 2005
Location: Houston, TX, .
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via Yahoo to tonyrosen
Default

I had declared the variables as String ... once I changed them to Date, it worked great.

Thanks!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off




All times are GMT -4. The time now is 06:49 PM.


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