Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula to return string between chars from right? 1

Status
Not open for further replies.

JGKWORK

IS-IT--Management
Apr 1, 2003
342
0
0
GB
Hi,

How do I create a formula to return a string from the following (between the last "\"'s)?


\Asbestos\Inspection\001_Dscf0026_2009-09-06.JPG\

I want to return:

001_Dscf0026_2009-09-06.JPG

Many thanks.
 
Sorry meant to say I need this to be a formula in an Excel cell. Thanks.
 


Hi,

Simplest way, paste this into a MODULE and use as you would any other spreadsheet function...
Code:
Function LastBit(rng As Range) As String
  LastBit = Split(rng.Value, "\")(UBound(Split(rng.Value, "\")) - 1)
End Function


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Really appreciate that but I'm up against it with time and I don't really know VBA or how to impliment it is there any way to do this with a formula?

Many thanks.
 
alt+F11 toggles to the VB editor

Insert > Module

Paste

alt+F11 toggles to the sheet

in the cell you need this formula, and assuming that your data is in A1...
[tt]
=LastBit(A1)
[/tt]
Its THAT SIMPLE!


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Superb, worked great and I learned something very useful, many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top