Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
find in reverse | Excel Worksheet Functions | |||
Reverse Find | Excel Discussion (Misc queries) | |||
reverse value | Excel Worksheet Functions | |||
How do I do a Reverse Find/Search in Excel? | Excel Worksheet Functions | |||
In Reverse... | Excel Programming |