ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Truncate text (https://www.excelbanter.com/excel-programming/294342-re-truncate-text.html)

Rob van Gelder[_4_]

Truncate text
 
Sorry - perhpas you mean you wanted everything to the left of the last
slash?

Sub test()
Dim str As String

str = "abcde/fghij/klmno/pqrst"
str = Left(str, InStrRev(str, "/") - 1)
End Sub

or the first slash?

Sub test()
Dim str As String

str = "abcde/fghij/klmno/pqrst"
str = Left(str, InStr(str, "/") - 1)
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Rob van Gelder" wrote in message
news:...
I think InStrRev is XL2000

Sub test()
Dim str As String

str = "abcde/fghij/klmno/pqrst"
str = Mid(str, InStrRev(str, "/"))
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"JAmes" wrote in message
...
Hi Gang
How can I truncate text to the right of and including / in a cell. Woul

dlike to do it through code
Thanks!







All times are GMT +1. The time now is 06:16 AM.

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