Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Reverse find


Is there a built-in function to find the last space in a string? In
other words, I want to search within a string from right to left.


--
cooldyood
------------------------------------------------------------------------
cooldyood's Profile: http://www.excelforum.com/member.php...o&userid=35611
View this thread: http://www.excelforum.com/showthread...hreadid=564043

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Reverse find

On Sat, 22 Jul 2006 21:13:29 -0400, cooldyood
wrote:


Is there a built-in function to find the last space in a string? In
other words, I want to search within a string from right to left.


Number of Last Space:

=FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))


--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default Reverse find

untested:

anyS ="cell.value
for I = len(anyS) to 1 step -1
if mid(anys, i,1) = " " then
msgbox "last space found"
exit for
end if
next

Bob Flanagan
Macro Systems
144 Dewberry Drive
Hockessin, Delaware, U.S. 19707

Phone: 302-234-9857, cell 302-584-1771
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"cooldyood" wrote
in message ...

Is there a built-in function to find the last space in a string? In
other words, I want to search within a string from right to left.


--
cooldyood
------------------------------------------------------------------------
cooldyood's Profile:
http://www.excelforum.com/member.php...o&userid=35611
View this thread: http://www.excelforum.com/showthread...hreadid=564043



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Reverse find

On Sat, 22 Jul 2006 21:22:25 -0400, Ron Rosenfeld
wrote:

On Sat, 22 Jul 2006 21:13:29 -0400, cooldyood
wrote:


Is there a built-in function to find the last space in a string? In
other words, I want to search within a string from right to left.


Number of Last Space:

=FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))


--ron


I overlooked that this is the Programming group. The VBA function you want is
InStrRev.

==============================
Option Explicit

Sub LastSpace()
Const sTestString As String = "This is a Test"
Dim lLastSpace As Long
Const sSpace As String = " "

lLastSpace = InStrRev(sTestString, sSpace)

Debug.Print "The Last Space is at location " & lLastSpace

End Sub
===============================
The Last Space is at location 10
-----------------------------------


--ron
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
find in reverse smw Excel Worksheet Functions 10 March 18th 09 01:48 PM
Reverse Find snax500 Excel Discussion (Misc queries) 4 August 1st 07 09:33 PM
reverse value rb Excel Worksheet Functions 1 March 28th 07 02:51 AM
How do I do a Reverse Find/Search in Excel? NumberDocc Excel Worksheet Functions 2 February 27th 06 10:55 PM
In Reverse... stck2mlon[_13_] Excel Programming 12 June 2nd 04 11:45 PM


All times are GMT +1. The time now is 04:39 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"