Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default if statements vs date ranges


Hi again!

Is it possible to do this in excel

dim date1 datee etc as date

date = Format(Range("b5").Value, "dd/mm/yyyy") (b5 is a date cell i
dd/mm/yyyy format - excel pushes the value into mm/dd/yyyy otherwise)

date2 = Format(#10/1/2004#, "dd/mm/yyyy")
date3 etc etc

if date date2 AND date < date3 then
code
elseif date date4 AND date < date4 then
code
else
code
endif


Its really the AND operator that I am having trouble with. I tried
case statement but that didnt work either.

Sorry to clog up the user group with basic questions but I have bee
out of the game for a little while

:) :

--
underhil
-----------------------------------------------------------------------
underhill's Profile: http://www.excelforum.com/member.php...nfo&userid=478
View this thread: http://www.excelforum.com/showthread.php?threadid=27438

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default if statements vs date ranges

You cannot use date as a variable, as this is a built-in referring to today.

Also, format will look to return a string not a date. Try something like

dim date1 datee etc as date

date1 = CDate(Range("b5").Value
date2 = CDate("2004/10/1")

if date date2 AND date < date3 then
code
elseif date date4 AND date < date4 then
code
else
code
endif

--

HTH

RP
(remove nothere from the email address if mailing direct)


"underhill" wrote in message
...

Hi again!

Is it possible to do this in excel

dim date1 datee etc as date

date = Format(Range("b5").Value, "dd/mm/yyyy") (b5 is a date cell in
dd/mm/yyyy format - excel pushes the value into mm/dd/yyyy otherwise)

date2 = Format(#10/1/2004#, "dd/mm/yyyy")
date3 etc etc

if date date2 AND date < date3 then
code
elseif date date4 AND date < date4 then
code
else
code
endif


Its really the AND operator that I am having trouble with. I tried a
case statement but that didnt work either.

Sorry to clog up the user group with basic questions but I have been
out of the game for a little while

:) :)


--
underhill
------------------------------------------------------------------------
underhill's Profile:

http://www.excelforum.com/member.php...fo&userid=4786
View this thread: http://www.excelforum.com/showthread...hreadid=274386



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
Using if statements with a date Stonsey Excel Worksheet Functions 6 December 7th 09 09:56 AM
If statements refering to data validated ranges skimark Excel Worksheet Functions 2 June 22nd 09 10:38 PM
Selectively replace cells based on two ranges of criteria - nestedIF() statements? MCSmarties Excel Discussion (Misc queries) 1 May 21st 08 09:49 PM
IF statements with more than one date column fyrefox Excel Worksheet Functions 5 December 24th 07 02:07 PM
IF statements and ranges Idz21 Excel Worksheet Functions 3 February 22nd 06 09:22 PM


All times are GMT +1. The time now is 05:46 PM.

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

About Us

"It's about Microsoft Excel"