conditional msgbox

  • Thread starter Thread starter fullymooned
  • Start date Start date
F

fullymooned

i need to write a macro such that if value is between 0.8 and 1.7 i
shoud say bad, between 1.7 and 2.71 msgbox shud say very bad and abov
2.71 it should be severe.

thank yo
 
With little info to go on, here goes...


Code
-------------------
Sub Test()
Dim rValue as Double

rValue = Range("A1").Value

If rValue >0.8 and rValue < 1.7 Then
MsgBox "Bad"
ElseIf rValue >1.7 and <2.71 Then
Msgbox "Very Bad"
ElseIf rValue >2.71 Then
Msgbox "Severe"
End If

End Su
 
Hi
try something like the following:
sub foo()
dim ret
dim ret_str
ret = range("A1").value
if ret >=0.8 and ret<1.7 then
ret_str = "bad"
elseif ret >=1.7 and ret<2.71 then
ret_str = "very bad"
elseif ret >=2.71 then
ret_str = "severe"
end if
msgbox ret_str
end sub
 
Why not just a formula?

=LOOKUP(ROUND(A1,2),{0.8,1.69,2.72},{"bad","very
bad","severe"})

Note: I'm rounding to the nearest hundreth decimal place,
so 2.713 would read "very bad".

HTH
Jason
Atlanta, GA
 

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

Back
Top