als vba anfänger hat udo mir folgendes erstellt:
Const strPath As String = "c:\temp\test"
Private Sub CommandButton1_Click()
ThisWorkbook.SaveAs strPath & "\" & Range("A1") & Range("A2") & FileIndex(strPath) & ".xls"
End Sub
Private Function FileIndex(strPath As String) As String
Dim FS As FileSearch, lngFiles As Long, lngMax As Long
Set FS = Application.FileSearch
With FS
.LookIn = strPath
.Filename = "*.xls"
.SearchSubFolders = True
If .Execute > 0 Then
For lngFiles = 1 To .FoundFiles.Count
If Left(Right(.FoundFiles(lngFiles), 9), 5) * 1 > lngMax Then
lngMax = Left(Right(.FoundFiles(lngFiles), 9), 5) * 1
End If
Next lngFiles
End If
End With
FileIndex = Format(lngMax + 1, "_00000")
End Function
- was muß noch eingefügt werden, damit der ermittelte zahlenwert in zelle g4 erscheint?