value lessthan x and greaterthan y

J

justzach

my excel file lists files in a certain folder (txt files to be imported
in columnA, lists the dates those files were modified in columnB, an
columnC shows the dates in columnB in general form (ex. 37866). Column
lists when certain reports should be run in general date format. i a
trying to tell VB to make sure the date from columnC is between th
values in two fields in columnF to know if the report should be run
below is the code i have written, but excel still runs the report eve
if i put in dates that not not make the IF statements true, thus shoul
not run the reports. here is a snippet of the code :

Sub Summer2()

Sheets("Extra").Select
If Range("F20") <= Range("C2") <= Range("F23") Then
SummerPasteData
SummerAdminReports
End If

Sheets("Extra").Select
If Range("F21") <= Range("C2") <= Range("F22") Then
SummerStudentReports
End If

End Sub

any ideas? is this not how to tell VB to compare one value ot make sur
it is greaterthan one and less than another? i could not find anythin
in VB help or on this board that would show how to combine compariso
operators such as the one above i am attempting. thanks in advance fo
your help
 
F

Frank Kabel

Hi
change the line
If Range("F20") <= Range("C2") <= Range("F23") Then

to
If Range("F20").value <= Range("C2").value and _
Range("C2").value <= Range("F23").value Then
 
A

Andoni

Try this!



Sub Summer2()

Sheets("Extra").Select
If Range("F20") <= Range("C2") Then
If Range("C2") <= Range("F23") Then
SummerPasteData
SummerAdminReports
End If
End If
Sheets("Extra").Select
If Range("F21") <= Range("C2") Then
If Range("C2") <= Range("F22") Then
SummerStudentReports
End If
End If

End Su
 
J

justzach

thanks frank! man, i knew it had to be possible, but i couldn't find i
anywhere! i really appreciate all the help you give to this board,
know personally your tips and help have helped me be able to create
great excel project!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top