LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default If Statement problem

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



 
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
IF Statement Problem SixBowls Excel Discussion (Misc queries) 4 December 11th 09 05:33 PM
If statement problem Scott@CW Excel Discussion (Misc queries) 2 October 5th 07 03:22 AM
IF Statement problem MarkFrost39 Excel Worksheet Functions 0 September 6th 07 02:50 PM
IF statement problem webstju Excel Worksheet Functions 3 April 21st 06 12:58 PM
Problem with IF statement Jonibenj Excel Discussion (Misc queries) 5 August 18th 05 12:06 AM


All times are GMT +1. The time now is 12:15 PM.

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"