Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
finding last space in a text function
I want to locate the last space in a text string, so that i may reproduce the
string without the characters which occur after the space. Foe example if i have "Hydrochloric acid 1M" as the string, i would like to produce "Hydrochloric acid" from this. The text string can vary in length as can the final text to be removed Can anyone help? Thanks, Roger |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
finding last space in a text function
On Sun, 20 Jul 2008 18:18:10 -0700, Roger on Excel
wrote: I want to locate the last space in a text string, so that i may reproduce the string without the characters which occur after the space. Foe example if i have "Hydrochloric acid 1M" as the string, i would like to produce "Hydrochloric acid" from this. The text string can vary in length as can the final text to be removed Can anyone help? Thanks, Roger To get the position of the last space in a string in A1: =FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1), LEN(A1)-LEN(SUBSTITUTE(A1," ","")))) To return everything up to the last space: =LEFT(A1,FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1), LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))-1) --ron |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
finding last space in a text function
In VBA use the InStrRev function......
sText = Left(Range("A1"), InStrRev(Range("A1"), " ") - 1) -- Regards, Nigel "Roger on Excel" wrote in message ... I want to locate the last space in a text string, so that i may reproduce the string without the characters which occur after the space. Foe example if i have "Hydrochloric acid 1M" as the string, i would like to produce "Hydrochloric acid" from this. The text string can vary in length as can the final text to be removed Can anyone help? Thanks, Roger |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help finding the last space in a cell | Excel Worksheet Functions | |||
Finding (and eliminating) hidden "space" character | Excel Discussion (Misc queries) | |||
Space in text | Excel Discussion (Misc queries) | |||
Space after Mid Function | Excel Discussion (Misc queries) | |||
Function to remove a space from text in cell WITHOUT macro?? | Excel Worksheet Functions |