#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Date comparison

I have a Named Range/Cell, "JanMtg". In my program, I have the following
statements:

Xval = 0

If CheckBox1.Value = True And Range("JanMtg").Value <= Date Then
Xval = 1
Else
MsgBox "Attendance data must be historic. Please select an earlier
month!"
GoTo AllDone
End If

I've tried every combination that I can think of and still the date test
fails. Without the date test it works fine. Any help will be greatly
appreciated.

Tom
  #2   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Date comparison

when I have problems like this i add some temporary lines with

cells(1,1)= Range("JanMtg").Value
cells(1,2)= CheckBox1.Value
cells(1,3)= Date

of course selecting cells which do not have other data
running the macro and checking I get what I think I should get.
what do you get when you have these lines in the macro.

"TomD" wrote:

I have a Named Range/Cell, "JanMtg". In my program, I have the following
statements:

Xval = 0

If CheckBox1.Value = True And Range("JanMtg").Value <= Date Then
Xval = 1
Else
MsgBox "Attendance data must be historic. Please select an earlier
month!"
GoTo AllDone
End If

I've tried every combination that I can think of and still the date test
fails. Without the date test it works fine. Any help will be greatly
appreciated.

Tom

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Date comparison

Hi BJ,

I haven't tried that. I know that all spreadsheet applications are cell
oriented, but I'm of the opinion that there should be a solution
programaticlly. If not, I will definitely use your example.

Thanks,
Tom

"bj" wrote:

when I have problems like this i add some temporary lines with

cells(1,1)= Range("JanMtg").Value
cells(1,2)= CheckBox1.Value
cells(1,3)= Date

of course selecting cells which do not have other data
running the macro and checking I get what I think I should get.
what do you get when you have these lines in the macro.

"TomD" wrote:

I have a Named Range/Cell, "JanMtg". In my program, I have the following
statements:

Xval = 0

If CheckBox1.Value = True And Range("JanMtg").Value <= Date Then
Xval = 1
Else
MsgBox "Attendance data must be historic. Please select an earlier
month!"
GoTo AllDone
End If

I've tried every combination that I can think of and still the date test
fails. Without the date test it works fine. Any help will be greatly
appreciated.

Tom

  #4   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Date comparison

the pupose of the cells is just to verify that the variables give the correct
answer. I didn't see anything wrong with the code you wrote so feel that one
of the variables may not be doing what you think it is doing, This happens to
me a lot.
after I trouble shoot I then remove the code

"TomD" wrote:

Hi BJ,

I haven't tried that. I know that all spreadsheet applications are cell
oriented, but I'm of the opinion that there should be a solution
programaticlly. If not, I will definitely use your example.

Thanks,
Tom

"bj" wrote:

when I have problems like this i add some temporary lines with

cells(1,1)= Range("JanMtg").Value
cells(1,2)= CheckBox1.Value
cells(1,3)= Date

of course selecting cells which do not have other data
running the macro and checking I get what I think I should get.
what do you get when you have these lines in the macro.

"TomD" wrote:

I have a Named Range/Cell, "JanMtg". In my program, I have the following
statements:

Xval = 0

If CheckBox1.Value = True And Range("JanMtg").Value <= Date Then
Xval = 1
Else
MsgBox "Attendance data must be historic. Please select an earlier
month!"
GoTo AllDone
End If

I've tried every combination that I can think of and still the date test
fails. Without the date test it works fine. Any help will be greatly
appreciated.

Tom

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Date comparison

Hi BJ,

Ok, I did that, and the values in the cells are correct. But, even if I
substitute these statements, it still fails.

Range("D105").Value = CheckBox1.Value 'The value is "True"
Range("D106").Value = Range("JanMtg").Value 'The value is "1/4/2007"
Range("D107").Value = Date 'The value is
"2/20/2007"

' If CheckBox1.Value = True And Range("JanMtg").Value <= Date Then
If Range("D105").Value = True And Range("D106").Value <=
Range("D107").Value Then
Xval = 1
Else
MsgBox "Attendance data must be historic. Please select an earlier
month!"
GoTo AllDone
End If

I also tried separating them into a nested "If" and it still fails.


"bj" wrote:

the pupose of the cells is just to verify that the variables give the correct
answer. I didn't see anything wrong with the code you wrote so feel that one
of the variables may not be doing what you think it is doing, This happens to
me a lot.
after I trouble shoot I then remove the code

"TomD" wrote:

Hi BJ,

I haven't tried that. I know that all spreadsheet applications are cell
oriented, but I'm of the opinion that there should be a solution
programaticlly. If not, I will definitely use your example.

Thanks,
Tom

"bj" wrote:

when I have problems like this i add some temporary lines with

cells(1,1)= Range("JanMtg").Value
cells(1,2)= CheckBox1.Value
cells(1,3)= Date

of course selecting cells which do not have other data
running the macro and checking I get what I think I should get.
what do you get when you have these lines in the macro.

"TomD" wrote:

I have a Named Range/Cell, "JanMtg". In my program, I have the following
statements:

Xval = 0

If CheckBox1.Value = True And Range("JanMtg").Value <= Date Then
Xval = 1
Else
MsgBox "Attendance data must be historic. Please select an earlier
month!"
GoTo AllDone
End If

I've tried every combination that I can think of and still the date test
fails. Without the date test it works fine. Any help will be greatly
appreciated.

Tom

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
date comparison help CathyZ Excel Discussion (Misc queries) 5 May 4th 06 11:53 AM
Date Comparison with VLookup techiemom60 Excel Worksheet Functions 1 March 26th 06 10:00 PM
Date comparison Darkdrew Excel Worksheet Functions 7 March 23rd 06 04:22 PM
Date comparison Jonibenj Excel Discussion (Misc queries) 6 October 23rd 05 08:34 PM
Excel - date comparison stormsailor Excel Discussion (Misc queries) 2 July 19th 05 05:46 AM


All times are GMT +1. The time now is 08:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"