Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: VBA mid() function in microsoft.public.excel.programming

Started 1 month, 2 weeks ago by vello
Using XP & Excel2002 to find a string in another string, gets me weird results: Dim S As String Dim L As Long S = "0123456789" For L = 1 To 10 Debug.Print Mid$(S, L, L) Next The above code returns the correct value only on the 1st iteration. Thereafter the Mid$ keeps growing....
Site: Discussions in microsoft.public.excel.programming  Discussions in microsoft.public.excel.programming - site profile
Forum: microsoft.public.excel.programming  microsoft.public.excel.programming - forum profile
Total authors: 6 authors
Total thread posts: 9 posts
Thread activity: no new posts during last week
Domain info for: microsoft.com

Other posts in this thread:

Jacob Skaria replied 1 month, 2 weeks ago
If you are looking to find a string in another string use INSTR()..Check out the help on VBA InStr() If this post helps click Yes --------------- Jacob Skaria "vello" wrote: > Using XP & Excel2002 to find a string in another string, gets me weird results: > Dim S As String > Dim L As Long...

Mike H replied 1 month, 2 weeks ago
I'm not sure what your trying to do but the code will return 0 12 234 3456 45678 56789 6789 789 89 9 The reason it does that is for every loop L increases by 1 and your using L as both start position and lengthe of text to return so in (say) the 4th iteration of the loop your ...

Charlie replied 1 month, 2 weeks ago
Debug.Print Mid$(S, L, 1) Use a 1 not "L" "vello" wrote: > Using XP & Excel2002 to find a string in another string, gets me weird results: > Dim S As String > Dim L As Long > > S = "0123456789" > For L = 1 To 10 > Debug.Print Mid$(S, L, L) > Next > > The...

Peter T replied 1 month, 2 weeks ago
change > Debug.Print Mid$(S, L, L) to Debug.Print Mid$(S, L, 1) at least that's what I assume you want! Regards, Peter T "vello" <vello@discussions.microsoft.com> wrote in message news:5688D375-6F6E-4514-AE9E-F8CC75C1C853@micros oft.com... > Using XP & Excel2002 to find a string in ...

Rick Rothstein replied 1 month, 2 weeks ago
Your posting is not very clear. You say you want to "find a string in another string", but the code you posted doesn't even come close to doing that. Exactly what are you trying to do? Try to give an example that demonstrates whatever it is. -- Rick (MVP - Excel) "vello" <vello@discussions.microsoft.com> ...

Rick Rothstein replied 1 month, 2 weeks ago
I'm not "picking" on your Charlie, it's just I needed to attach this note to either you message or Peter T's message... I chose yours. Both you and Peter made the same suggestion (to change the second L to a one)... my question to the both of you is... How does that explain the OP's statement "The above code ...

vello replied 1 month, 2 weeks ago
Thanks to all of you for your notes. Now I see where the problem was. What I want to do is to find a certain 'word' in a textstream and then place it in an Excel cell. Seems to me there was an API that did this well, but can't remember it. "Rick Rothstein" wrote: > Your posting is not very clear. You say you want ...

Charlie replied 1 month, 2 weeks ago
Did I miss something? On the first iteration L would equal 1. The loop is from 1 to 10 -- the STRING started at zero ("0123...") "Rick Rothstein" wrote: > I'm not "picking" on your Charlie, it's just I needed to attach this note to > either you message or Peter T's message... I chose yours. > > Both you and ...

 

Top contributing authors

Name
Posts
Rick Rothstein
2
user's latest post:
VBA mid() function in...
Published (2009-11-02 15:14:00)
&nbsp; I'm not &quot;picking&quot; on your Charlie, it's just I needed to attach this note to either you message or Peter T's message... I chose yours. Both you and Peter made the same suggestion (to change the second L to a one)... my question to the both of you is... How does that explain the OP's statement &quot;The above code returns the correct value only on the 1st iteration&quot;? It would seem...
vello
2
user's latest post:
VBA mid() function in...
Published (2009-11-02 18:15:00)
&nbsp; Thanks to all of you for your notes. Now I see where the problem was. What I want to do is to find a certain 'word' in a textstream and then place it in an Excel cell. Seems to me there was an API that did this well, but can't remember it. &quot;Rick Rothstein&quot; wrote: &gt; Your posting is not very clear. You say you want to &quot;find a string in &gt; another string&quot;, but the code...
Charlie
2
user's latest post:
VBA mid() function in...
Published (2009-11-03 04:55:00)
&nbsp; Did I miss something? On the first iteration L would equal 1. The loop is from 1 to 10 -- the STRING started at zero (&quot;0123...&quot;) &quot;Rick Rothstein&quot; wrote: &gt; I'm not &quot;picking&quot; on your Charlie, it's just I needed to attach this note to &gt; either you message or Peter T's message... I chose yours. &gt; &gt; Both you and Peter made the same...
Mike H
1
user's latest post:
VBA mid() function in...
Published (2009-11-02 09:43:00)
&nbsp; I'm not sure what your trying to do but the code will return 0 12 234 3456 45678 56789 6789 789 89 9 The reason it does that is for every loop L increases by 1 and your using L as both start position and lengthe of text to return so in (say) the 4th iteration of the loop your formula is Debug.Print Mid$(&quot;0123456789&quot;, 4, 4) From this you should be able to work out why the returned string gets shorter when L=6...
Jacob Skaria
1
user's latest post:
VBA mid() function in...
Published (2009-11-02 09:26:00)
&nbsp; If you are looking to find a string in another string use INSTR()..Check out the help on VBA InStr() If this post helps click Yes --------------- Jacob Skaria &quot;vello&quot; wrote: &gt; Using XP &amp; Excel2002 to find a string in another string, gets me weird results: &gt; Dim S As String &gt; Dim L As Long &gt; &gt; S = &quot;0123456789&quot; &gt; For L = 1 To 10 &gt; Debug.Print...
Peter T
1
user's latest post:
VBA mid() function in...
Published (2009-11-02 15:04:00)
&nbsp; change &gt; Debug.Print Mid$(S, L, L) to Debug.Print Mid$(S, L, 1) at least that's what I assume you want! Regards, Peter T &quot;vello&quot; &lt;vello@discussions.microsoft.com&gt; wrote in message news:5688D375-6F6E-4514-AE9E-F8CC75C1C853@microsoft.com... &gt; Using XP &amp; Excel2002 to find a string in another string, gets me weird &gt; results: &gt; Dim S As String &gt; Dim L As...

Related threads on "Discussions in microsoft.public.excel.programming":

Related threads on other sites:

Thread profile page for "VBA mid() function in microsoft.public.excel.programming" on http://www.microsoft.com/communities/newsgroups.... This report page is a snippet summary view from a single thread "VBA mid() function in microsoft.public.excel.programming", located on the Message Board at http://www.microsoft.com/communities/newsgroups.... This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity