Re: How to trim cell information
- From: "Rick Rothstein \(MVP - VB\)" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Mon, 22 Oct 2007 14:40:07 -0400
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
.
- Follow-Ups:
- Re: How to trim cell information
- From: Ron Rosenfeld
- Re: How to trim cell information
- References:
- Re: How to trim cell information
- From: Ron Rosenfeld
- Re: How to trim cell information
- Prev by Date: Re: Change Project Name
- Next by Date: Re: Data replacement
- Previous by thread: Re: How to trim cell information
- Next by thread: Re: How to trim cell information
- Index(es):
Relevant Pages
|