Hi, is there is a way to chop off the last 4 characters of a string?
I have a group of text file names and I want to delete the ".txt" part
at the end of the names.
Thanks
Since you're in the programming group, here is a VBA example:
Sub foo()
Const str As String = "foobar.txt"
Debug.Print Replace(str, ".txt", "")
End Sub
The above is case sensitive. If you want to do a case insensitive replacement,
then:
Option Compare Text
Sub foo()
Const str As String = "foobar.TXT"
Debug.Print Replace(str, ".txt", "")
End Sub
If you are doing this on a worksheet:
=SUBSTITUTE(A1,".txt","")
=REPLACE(A1,SEARCH(".txt",A1),4,"")
The SUBSTITUTE function is case sensitive. The other is not.
--ron