insanity82007
Board Regular
- Joined
- Oct 10, 2007
- Messages
- 130
I built this function to find the last character in a string primarily for file renaming so that it would find the last "\" in a directory tree so that I could extract the file name from the list using a mid function after that.
When I run it for lots of rows it slows down heaps and takes ages to calc. Any ideas on how I can improve this?
Cheers
When I run it for lots of rows it slows down heaps and takes ages to calc. Any ideas on how I can improve this?
Cheers
Function FindLast(ByVal inpt As String, what As String) As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For i = 1 To Len(inpt)
If Mid(inpt, i, Len(what)) = what Then
FindLast = i
End If
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Function