If Statement problem
Your code is testing for the 1st of the month, but your data shows only
January on the 1st. Feb thru May dates are the second day of the month, so
code fails to find 02/01/2005, etc.
Is this your problem? Mis-entered dates?
PS did my code help with your last post about updating the date list?
Mike F
"Robert Hargreaves" wrote in message
...
I am trying to set up an If statement and I am using a message box to test
if the code is working or not.
Following the Then in the If statement I will include a different range of
rows to be removed to take out 1 month from the beginning of the
spreadsheet.
My test code only gives a message box saying 1st January 2005 not feb
march etc. Why is this?
Here is my sheet
Row 1
Row 2
Row 3
01/01/2005
02/02/2005
03/02/2005
04/02/2005
05/02/2005
06/02/2005
....
here is my code
If ActiveSheet.Range("$A$4").Value = #1/1/2005# Then
MsgBox ("The date is 1st Jan 2005"), vbInformation
ElseIf ActiveSheet.Range("$A$4") = #1/2/2005# Then
MsgBox ("The date is 1st Feb 2005"), vbInformation
ElseIf ActiveSheet.Range("$A$4") = #1/3/2005# Then
MsgBox ("The date is 1st Mar 2005"), vbInformation
ElseIf ActiveSheet.Range("$A$4") = #1/4/2005# Then
....
it will look like this though when its working instead of testing...
If ActiveSheet.Range("$A$4").Value = #1/1/2005# Then
ActiveSheet.Rows("4:34").Delete
ElseIf ActiveSheet.Range("$A$4") = #1/2/2005# Then
ActiveSheet.Rows("4:31").Delete
Thanks for any suggestions
Rob
|