Ersatzfunktion für Split
28.11.2013 14:50:54
KlausF
Hallo Martin,
anbei die Ersatzfunktion mit deinem Code:
Sub DateinameKorrekt()
Dim strfilename As String, arrfilename As Variant
Dim strNew As String
strfilename = "21.10.2013.xls"
arrfilename = SplitVBA(strfilename, ".")
strNew = Left(strfilename, Len(strfilename) - Len(arrfilename(UBound(arrfilename))) - 1)
MsgBox strNew
End Sub
Function SplitVBA(strText As String, Trenner As String)
Dim a As Long, b As Long, c() As String
Dim d As Long, vorher As Long
d = Len(Trenner)
vorher = 1
ReDim c(1 To Len(strText) \ d + 1)
Do
b = InStr(vorher, strText, Trenner)
If b = 0 Then
c(a + 1) = Mid$(strText, vorher, Len(strText))
If c(a + 1) = "" Then a = a - 1
Exit Do
Else
c(a + 1) = Mid$(strText, vorher, b - vorher)
End If
vorher = b + d
a = a + 1
Loop
ReDim Preserve c(1 To a + 1)
SplitVBA = c
End Function
Ich glaube, die Ersatzfunktion stammt von Michael Schwimmer ...
Gruß
Klaus