Within Range ? Greater than, etc.

D

Dave Piper

Hello,

Thanks in advance for your help.

I need some newbie help...

I'm looking for a function that will perform the following:

In cell C2, check the value of B2 and produce a corresponding number.

So if the value in B2 is less than or equal to 24 then return 0, if
greater than 24 and less than or equal to 48 then return 1, if greater
than 48 and less than or equal to 72 then return 2, if greater than 72
and less than or equal to 96 then return 3, if greater than 96 and less
than or equal to 120 then return 4, and lastly if greater than 120 and
less than or equal to 144, then return 5.

Thanks again,

DP
 
A

Anders S

Already answered in .worksheet.functions.

Please do not multipost.

Regards
Anders Silven
 
G

Guest

Well, here's a function. It's not a worksheet function
though.

-IA

Sub TimeTrial()
PresentLocation = Range("C2").Value
EvaluatedLocation = Range("B2").Value
HoursElapsed PresentLocation, EvaluatedLocation
Range("C2").Value = PresentLocation
End Sub

Function HoursElapsed(PresentLocation, EvaluatedLocation)
Select Case True
Case EvaluatedLocation <= 24
PresentLocation = 0
Case EvaluatedLocation > 24 And EvaluatedLocation <= 48
PresentLocation = 1
Case EvaluatedLocation > 48 And EvaluatedLocation <= 72
PresentLocation = 2
Case EvaluatedLocation > 72 And EvaluatedLocation <= 96
PresentLocation = 3
Case EvaluatedLocation > 96 And EvaluatedLocation <= 120
PresentLocation = 4
Case EvaluatedLocation >120 And EvaluatedLocation <= 144
PresentLocation = 5
End Select
End Function
 

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