View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default space from right

Look up the InStrRev function in the help files... it will produce much more
efficient code...

Function LastOfThese(LineOfText As String, Character As String) As Long
LastOfThese = InStrRev(LineOfText, Character)
End Function

--
Rick (MVP - Excel)


"Robin Clay" <Robin_B DOT Clay AT virgin DOT net wrote in message
...
Public Function LastOfThese(LineOfText$, Character$) As Integer
' Finds the position of the last time the Character appears in the
LineOfText
' e.g. "0123456,789,012,345,67,8,9,000" and "," gives 27
' It returns Zero if the Character does not appear in the LineOfText

Dim N As Integer, C As Integer

LastOfThese = 0
For N = 1 To Len(LineOfText$)
If Mid$(LineOfText$, N, 1) = Character$ Then LastOfThese = N
Next N

End Function
--
Regards

Robin


"delmac" wrote:

HI all, has anyone got a formula for finding thwe 1st space from the
right of
a string
e.g. These can have variable lengths as they are all addresses
Gar 29 Durban Avenue Dalmuir West C

I want to find the space between West and C

Thanks all (again)
--
delmac