Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "silkworm" wrote in message ups.com... 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 If cell A1 contains a text value you want to parse, use this =Left(A1, Len(A1) - 4) HTH -gk- |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 21 Dec 2005 18:05:37 -0800, "silkworm" wrote:
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you very much, guys.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Counting Characters In A String | Excel Worksheet Functions | |||
Extract characters from Right of string | Excel Worksheet Functions | |||
Insert Leading Characters If String Is Only 7 Characters | Excel Discussion (Misc queries) | |||
Copy string of characters | Excel Discussion (Misc queries) | |||
how do I fit all data into a cell? Excel keeps chopping it into r | Excel Discussion (Misc queries) |