View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default multiple "IF" statements in function

put this into a standered Module
and use this formula in cell F1 =VactionTime(E1)
Function VactionTime(target As Range) As String
With target
Select Case .value
Case Is = 0
VactionTime = ""
Case Is <= 365
VactionTime = "0 Weeks"
Case Is <= 730
VactionTime = "1 Weeks"
Case Is <= 1825
VactionTime = "2 Weeks"
Case Is <= 3650
VactionTime = "3 Weeks"
Case Is 3650
VactionTime = "4 Weeks"
End Select
End With
End Function

"RRyan" wrote:

I'm trying to build a vacation tracker but i don't know VB. Is there a way
to get muliple if statements using the function built into excel? This is
what I would ike to use:
If (e) <= (365) Then
(f)= "0 Weeks"
End If
if (e) (365) and <= (730) then
(f) = "1 week"
End If
if (e) (730) and <= (1825) then
(f) = "2 Weeks"
End If
if (e) (1825) and <= (3650) then
(f) = "3 Weeks"
End If
If (e) (3650) Then
(f) = "4 Weeks"
End If
(e) and (f) are the columns
Thanks in advance
Rob