![]() |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 07:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com