Created
May 18, 2011 05:58
-
-
Save iseebi/978053 to your computer and use it in GitHub Desktop.
Excel VBA Macro for Filename processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Function dirname(ByVal inVal As String, Optional directorySeparater As String = "/") As String | |
Dim basenameStr As String | |
basenameStr = basename(inVal, directorySeparater) | |
If basenameStr <> inVal Then | |
dirname = Left(inVal, Len(inVal) - Len(basenameStr) - 1) | |
Else | |
dirname = "." | |
End If | |
End Function | |
Function basename(ByVal inVal As String, Optional directorySeparater As String = "/") As String | |
Dim index As Integer | |
index = InStrRev(inVal, directorySeparater) | |
If index > 0 Then | |
basename = Mid(inVal, index + 1) | |
Else | |
basename = Mid(inVal, index + 1) | |
End If | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment