Reputation: 11
Function GetPath() As String
Dim sFilepath As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
sFilepath = GetFolder()
If sFilepath = "" Then
MsgBox ("Invalid File Path! Select a File Path for the Folders.")
End If
End Function
This is beyond insane. All I want to do is return a value, a String, but when I type
Return sFilepath
At the end of the function I get a compiler error. I'm transitioning from Java to VBA and this is frustrating and embarrassing me. Gurus of the Internet, why can't I insert that Return statement and how do I do it correctly?
Upvotes: 0
Views: 65
Reputation: 8868
In VBA, Return is used for a different purpose. So instead of:
Return sFilePath
You need to write:
GetPath = sFilePath
Upvotes: 4