A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

backwards find function to find character in a string of text



 
 
Thread Tools Display Modes
  #1  
Old January 14th 04, 03:20 PM posted to microsoft.public.excel.programming
Ashleigh K.
external usenet poster
 
Posts: 7
Default backwards find function to find character in a string of text

Hello All,

I'm having a problem doing something that seems like it would be relatively
simple....I have a value in a cell which is actually the directory path and
name of another workbook (i.e.
\\Server1\clients\clientA\financials\financialstat ement.xls) and I would
like to get just the file name by itself. The name "financialstatements"
will vary, so I will need a function/macro that can take whatever is between
the last "\" and ".xls" and return that value to a cell. I have been unable
to use the right function with the find function because the find function
starts at the beginning of the string and therefore returns the first "\".
Is there a way to start from the end of the string instead of the beginning?
Thanks in advance,

Ashleigh


Ads
  #2  
Old January 14th 04, 04:36 PM posted to microsoft.public.excel.programming
Chip Pearson
external usenet poster
 
Posts: 7,247
Default backwards find function to find character in a string of text

Ashleigh,

In Excel 2000 and later, you can use the InStrRev function to
search right to left. E.g.,

Dim Pos As Long
Pos = InStrRev(S, "\", -1, vbTextCompare)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ashleigh K." > wrote in message
...
> Hello All,
>
> I'm having a problem doing something that seems like it would

be relatively
> simple....I have a value in a cell which is actually the

directory path and
> name of another workbook (i.e.
> \\Server1\clients\clientA\financials\financialstat ement.xls)

and I would
> like to get just the file name by itself. The name

"financialstatements"
> will vary, so I will need a function/macro that can take

whatever is between
> the last "\" and ".xls" and return that value to a cell. I have

been unable
> to use the right function with the find function because the

find function
> starts at the beginning of the string and therefore returns the

first "\".
> Is there a way to start from the end of the string instead of

the beginning?
> Thanks in advance,
>
> Ashleigh
>
>



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FIND 2nd character in a string Fuzzy Excel Worksheet Functions 7 September 1st 09 08:14 AM
find a character in a string kevcar40 Excel Discussion (Misc queries) 4 June 5th 07 12:10 PM
Find last occurance of character in text string JDay01 Excel Worksheet Functions 2 February 14th 06 04:29 PM
Find nth instance of a character in a string Francis Hayes (The Excel Addict) Excel Discussion (Misc queries) 7 January 21st 05 03:44 PM
How find character position # in string from right end? Or how get range row num Ian Elliott[_3_] Excel Programming 1 December 17th 03 03:56 PM


All times are GMT +1. The time now is 11:39 PM.


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