Re: How to trim cell information
- From: Ron Rosenfeld <ronrosenfeld@xxxxxxxxxx>
- Date: Mon, 22 Oct 2007 15:13:03 -0400
On Mon, 22 Oct 2007 14:40:07 -0400, "Rick Rothstein \(MVP - VB\)"
<rickNOSPAMnews@xxxxxxxxxxxxxxxxx> wrote:
For a UDF, which allows for file types of three or four characters, you
could
try this:
===============================
Option Explicit
Function reFilename(str As String) As String
Dim re As Object
Dim mc As Object
Const sPat As String = "\\([^\\\,]+)\..{3,4}$"
Set re = CreateObject("vbscript.regexp")
re.Pattern = sPat
If re.test(str) = True Then
Set mc = re.Execute(str)
reFilename = mc(0).submatches(0)
End If
End Function
==================================
Here is a UDF which works for any extension (even for a file with no
extension)...
Function GetFileName(FN As String) As String
If Len(FN) Then GetFileName = Split(Split(FN, "\") _
(UBound(Split(FN, "\"))), ".")(0)
End Function
Rick
That'll work, and is shorter and probably faster.
I could modify mine to handle the absence of a file type extension.
--ron
.
- Follow-Ups:
- Re: How to trim cell information
- From: Rick Rothstein \(MVP - VB\)
- Re: How to trim cell information
- References:
- Re: How to trim cell information
- From: Ron Rosenfeld
- Re: How to trim cell information
- From: Rick Rothstein \(MVP - VB\)
- Re: How to trim cell information
- Prev by Date: Count of rows with nulls
- Next by Date: Help with modifing code??
- Previous by thread: Re: How to trim cell information
- Next by thread: Re: How to trim cell information
- Index(es):
Relevant Pages
|