LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #21   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Fast way to truncate string

I was able to duplicate the exception by using a word that wasn't in
the string being truncated. That precludes that you need to know the
contents of the string being truncated contains the search string...

Function TruncateString$(sText$, sFind$, Optional lStart& = 1)
If InStr(sText, sFind) 0 Then
'Truncate
TruncateString = Mid$(sText, lStart, InStr(sText, sFind) - lStart)
Else
'Return original string
TruncateString = sText
End If
End Function

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


 
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
TRUNCATE SPACE FROM NUMERICAL STRING eg "33 033 546" NAEEM Excel Worksheet Functions 8 December 5th 06 07:30 PM
Truncate string bwmaher Excel Programming 3 November 8th 06 07:11 PM
Truncate string bwmaher Excel Programming 0 November 8th 06 01:17 PM
How do you truncate a text string? dailygluttony Excel Worksheet Functions 2 March 28th 06 08:08 PM
Any fast method to parse a string into row & col information Nick Excel Programming 3 August 19th 04 06:47 PM


All times are GMT +1. The time now is 04:47 PM.

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"