ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   spaces (https://www.excelbanter.com/excel-programming/389097-spaces.html)

delmac

spaces
 
Hi all, how do I find the first space from the right or the last space from
the left in a string of 30 chars e.g. "the rainfall is very heavy thi"

Thanks as always
--
delmac

Norman Jones

spaces
 
Hi Delmac,

Try something like:

'=============
Public Sub Tester()
Dim iPos As Long
Const sStr As String = "the rainfall is very heavy thi"

iPos = InStrRev(sStr, Space(1))
MsgBox iPos
End Sub
'<<=============



---
Regards,
Norman


"delmac" wrote in message
...
Hi all, how do I find the first space from the right or the last space
from
the left in a string of 30 chars e.g. "the rainfall is very heavy thi"

Thanks as always
--
delmac




Norman Jones

spaces
 
Hi Delmac,

I should have added that, IIRC, the InStrRev was
introduced in xl2K.


---
Regards,
Norman



papou

spaces
 
Hello
Use InstrRev.
eg:
InStrRev("the rainfall is very heavy thi", " ", -1, vbTextCompare)

This will return the position of the first space found strating from the
right.

HTH
Cordially
Pascal


"delmac" a écrit dans le message de news:
...
Hi all, how do I find the first space from the right or the last space
from
the left in a string of 30 chars e.g. "the rainfall is very heavy thi"

Thanks as always
--
delmac





All times are GMT +1. The time now is 11:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com