Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Truncate text

Hi Gan
How can I truncate text to the right of and including / in a cell. Woul dlike to do it through cod
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Truncate text

aCtivecell.value = left(activecell.value,instr(1,activecell.value,"/")-1)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"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!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Truncate text

If you mean you want to retain everything to the left of the "/" try:

Sub test()
Dim pos&, rng As Range
Set rng = Range("A1")
pos& = InStr(1, rng.Value, "/")
If pos& Then rng.Value = Left(rng.Value, pos& - 1)
End Sub

JAmes wrote:
Hi Gang
How can I truncate text to the right of and including / in a cell. Woul dlike to do it through code
Thanks!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Truncate text

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!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Truncate text

Can this be applied to a range or do I have to loop through the range
Thanks for the response!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Truncate text

No, you can set a value to a range, but for this you will need to loop
through each cell.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"James" wrote in message
...
Can this be applied to a range or do I have to loop through the range?
Thanks for the response!



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Truncate text

Hi
you have to loop through the range

--
Regards
Frank Kabel
Frankfurt, Germany

"James" schrieb im Newsbeitrag
...
Can this be applied to a range or do I have to loop through the

range?
Thanks for the response!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I truncate linked text? Jenni Excel Worksheet Functions 1 April 9th 10 07:10 PM
formula to truncate text characters MarkT Excel Discussion (Misc queries) 6 June 4th 09 04:19 PM
truncate text to first word Harry C Excel Discussion (Misc queries) 5 July 3rd 08 05:14 AM
How do you truncate a text string? dailygluttony Excel Worksheet Functions 2 March 28th 06 08:08 PM
truncate text using VBA Excel maehe Excel Programming 2 November 21st 03 12:58 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"