Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add a date in if formula?

Status
Not open for further replies.

xq

Programmer
Jun 26, 2002
106
NL
i need to add an adjust date in if formula, but "6/30/2002" is added in as string type in stead of date type. thanks a lot if anybody could help me!
that's the formula here:

worksheets("sheet1").range("D1:D10").formula = _
if(AND(Month(RC[-1])>6, Year(RC[-1])>2002), 6/30/2002, 0)

thanks again!
 
try something like

Worksheets("sheet1").Range("D1:D10").Formula = "=if(AND(Month(RC[-1])>6, Year(RC[-1])>2002), DATEVALUE(""6/30/2002""), """")"
 
thanks a lot, but doesn't work.
 
xq - it shouldn't matter if the date is added as a string value, as long as the format of the cell is set to date - excel looks at strings and if they are in a valid date format, converts to date.
Failing that, try
FORMAT(DATEVALUE(""6/30/2002""),"mm/dd/yyyy")
HTH
~Geoff~
[noevil]
 

Worked for me except it seems you might want it to be >= 2002.

.Range("D1:D10").Formula = _
"=if(AND(Month(RC[-1])>6, Year(RC[-1])>=2002), DATEVALUE(""6/30/2002""), """")"

 
thanks u guys! it does work now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top