Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Position of Chr(10)


I have a string with *Chr(10)* in it.

I want to know the position of this Chr(10) so I can cut off the string
starting from this Chr(10).

What function gives this position?

Thx


--
Zurn
------------------------------------------------------------------------
Zurn's Profile: http://www.excelforum.com/member.php...o&userid=14645
View this thread: http://www.excelforum.com/showthread...hreadid=387930

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Position of Chr(10)


Function SnipString(rng)
x = Mid(rng, Application.Find(Chr(10), rng) + 1, Len(rng))
Loc = x
End Function


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=387930

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Position of Chr(10)



in a worksheetfunction you'd use the search or find function
=SEARCH(CHAR(10),a1)

in VBA:

use the InStr function.
dim iPos%
ipos = instr("where's the linefeed", vblf)

xl2000 and newer also have an InstrRev() function
which search from the end of the string to give you the LAST occurance
of the substring.

note:
vblf is a constant used in VB(a) for chr(10)
vbcr = chr(13)

see VBA help for the full monty.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Zurn wrote :


I have a string with *Chr(10)* in it.

I want to know the position of this Chr(10) so I can cut off the
string starting from this Chr(10).

What function gives this position?

Thx

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Position of Chr(10)


David,

i would NOT use the FIND worksheetfunction for this.
it's many times slower than instr.

WHY then len(s)??
- it's optional for vba's mid function.
- it should be len(s) - iPos


Sub USEinstrNOTfind()
Dim s$, r$, n&, m&, t(1)
m = 100000
s = "Find the line" & vbLf & "feed"

t(0) = Timer
For n = 1 To m
r = Mid$(s, Application.Find(vbLf, s) + 1)
Next
t(0) = Format(Timer - t(0), "0.00")

t(1) = Timer
For n = 1 To m
r = Mid$(s, InStr(1, s, vbLf) + 1)
Next
t(1) = Format(Timer - t(1), "0.00")
MsgBox Join(t, vbLf)

End Sub



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


davidm wrote :


Function SnipString(rng)
x = Mid(rng, Application.Find(Chr(10), rng) + 1, Len(rng))
Loc = x
End Function

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
There is no row at position 0 Catbean Excel Discussion (Misc queries) 1 November 21st 08 11:24 PM
Look up a value which position changes. David_in_AUS Excel Discussion (Misc queries) 1 June 13th 06 09:01 AM
How can I fix the position of a row [email protected] Excel Discussion (Misc queries) 3 June 8th 06 10:27 PM
.position chazman Charts and Charting in Excel 4 February 28th 05 02:26 AM
Tab Position Robert[_16_] Excel Programming 3 January 6th 05 09:52 PM


All times are GMT +1. The time now is 12:41 AM.

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

About Us

"It's about Microsoft Excel"