Originally Posted by FRIEL
ACK! Sorry about that, and thank you for being so gracious in your correction. Your question was clear, my eyes were not
![]()
Maybe:
[VBA]Sub example()
MsgBox NextFolderNumber(ThisWorkbook.Path)
End Sub
Function NextFolderNumber(Path As String) As Long
Dim Folder As Object
Dim lTmp As Long
With CreateObject("Scripting.FileSystemObject")
If .FolderExists(Path) Then
For Each Folder In .GetFolder(Path).SubFolders
If Folder.Name Like "ENQ ####" Then
lTmp = CLng(Right(Folder.Name, 4))
If lTmp > NextFolderNumber Then NextFolderNumber = lTmp
End If
Next
End If
End With
End Function[/VBA]