View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default If statement not working


you can give this a try

Sub Test()
Dim mySourceWkbkName2 As String
If Range("F4") = "" Then
MsgBox "Enter Person Reporting in Cell F4"
Exit Sub
ElseIf Range("F4") = "Jay" Then
mySourceWkbkName2 = "F:\files\ProjTimeTracking.xls"
ElseIf Range("F4") = "Dave" Then
mySourceWkbkName2 = "H:\FAC\DaveSipes\DavProjTimeTracking.xls"
Else
MsgBox "Person Reporting name mispelled"
Exit Sub
End If
MsgBox (mySourceWkbkName2)

End Sub

--


Gary


"Jay" wrote in message
...
Two questions about the following code.
1- why is it not working?
2- is there a cleaner way to accomplish this?

Sub Test()

If Range("F4") = "" Then
MsgBox "Enter Person Reporting in Cell F4"
Exit Sub
End If

If Range("F4") = "Jay" Then
mySourceWkbkName2 = "F:\files\ProjTimeTracking.xls"
If Range("F4") = "Dave" Then
mySourceWkbkName2 = "H:\FAC\Dave
Sipes\DavProjTimeTracking.xls"
If Range("F4") < "" Then
MsgBox "Person Reporting name mispelled"
Exit Sub
End If
End If
End If

MsgBox (mySourceWkbkName2)

End Sub