Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default remove last part of string

I need to create a text string from a variable length file name by removing
the .xls from the end of the file name. It would be easy if the file names
were a fixed length, but they are not. Is there another easy way?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default remove last part of string

"Mitch" wrote in message
...
I need to create a text string from a variable length file name by removing
the .xls from the end of the file name. It would be easy if the file
names
were a fixed length, but they are not. Is there another easy way?


Hi Mitch,

Here's one way to do it:

Dim szFilename As String
Dim szNameOnly As String
szFilename = "My File Name.xls"
szNameOnly = Left$(szFilename, Len(szFilename) - 4)

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default remove last part of string

One way:

sFileName = Left(sFileName, Len(sFileName) - 4)

or, if you weren't sure whether the extension was there or not:

sFileName = Replace(sFileName, ".xls", "")

In article ,
"Mitch" wrote:

I need to create a text string from a variable length file name by removing
the .xls from the end of the file name. It would be easy if the file names
were a fixed length, but they are not. Is there another easy way?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vlookup part of string... [email protected] Excel Discussion (Misc queries) 6 October 24th 08 01:30 AM
Search/Match/Find ANY part of string to ANY part of Cell Value TWhizTom Excel Worksheet Functions 0 July 21st 08 08:16 PM
Extract Part of String [email protected] Excel Worksheet Functions 1 June 9th 05 08:33 AM
Remove part of string Erik Excel Programming 3 October 2nd 04 05:08 PM
extracting part of string value Dr. Schwartz[_3_] Excel Programming 3 April 23rd 04 01:23 PM


All times are GMT +1. The time now is 08:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"