Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Extract keyword from a string

Hello everybody,

Please kindly tell how to extract the key word "popular " by VBA function,
say Mid, how to:

Dim theString as String
theString = "Jeans are popular among the young."

Thanks & Regards.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Extract keyword from a string

What do you want, to check that it is there, or its position, or what?

myVar = Instr(1,"Jeans are popular among the young.","popular")

returns its position assuming it exists

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Hello everybody,

Please kindly tell how to extract the key word "popular " by VBA function,
say Mid, how to:

Dim theString as String
theString = "Jeans are popular among the young."

Thanks & Regards.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Extract keyword from a string

Thanks Bob,

Sorry for my expressions being not clear, say:

"c:\Files\Excel8\peter.xls"
"c:\Files\Excel888\michelle.xls"
"c:\Files\Excel88\may.xls"

I want to extract the *.xls name in a For Loop.

Thanks & Regards.



"Bob Phillips" wrote:

What do you want, to check that it is there, or its position, or what?

myVar = Instr(1,"Jeans are popular among the young.","popular")

returns its position assuming it exists

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Hello everybody,

Please kindly tell how to extract the key word "popular " by VBA function,
say Mid, how to:

Dim theString as String
theString = "Jeans are popular among the young."

Thanks & Regards.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Extract keyword from a string

You should work from the back then

Dim myVar As String

For i = Len(theString) To 1 Step -1
If Mid(theString, i, 1) = "\" Then
myVar = Mid(theString, i + 1, 99)
Exit For
End If
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Thanks Bob,

Sorry for my expressions being not clear, say:

"c:\Files\Excel8\peter.xls"
"c:\Files\Excel888\michelle.xls"
"c:\Files\Excel88\may.xls"

I want to extract the *.xls name in a For Loop.

Thanks & Regards.



"Bob Phillips" wrote:

What do you want, to check that it is there, or its position, or what?

myVar = Instr(1,"Jeans are popular among the young.","popular")

returns its position assuming it exists

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Hello everybody,

Please kindly tell how to extract the key word "popular " by VBA

function,
say Mid, how to:

Dim theString as String
theString = "Jeans are popular among the young."

Thanks & Regards.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Extract keyword from a string

Hi
just to add to Bob. Depending on your Excel version (Excel 2000+) you may
also have a look at InStrRev

e.g.
i=instrRev(theString,"/")
myVar = Mid(theString, i + 1, 99)

"Bob Phillips" wrote:

You should work from the back then

Dim myVar As String

For i = Len(theString) To 1 Step -1
If Mid(theString, i, 1) = "\" Then
myVar = Mid(theString, i + 1, 99)
Exit For
End If
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Thanks Bob,

Sorry for my expressions being not clear, say:

"c:\Files\Excel8\peter.xls"
"c:\Files\Excel888\michelle.xls"
"c:\Files\Excel88\may.xls"

I want to extract the *.xls name in a For Loop.

Thanks & Regards.



"Bob Phillips" wrote:

What do you want, to check that it is there, or its position, or what?

myVar = Instr(1,"Jeans are popular among the young.","popular")

returns its position assuming it exists

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Hello everybody,

Please kindly tell how to extract the key word "popular " by VBA

function,
say Mid, how to:

Dim theString as String
theString = "Jeans are popular among the young."

Thanks & Regards.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Extract keyword from a string


Why add the 99 as the length of the MID?


in a worksheetfunction you'll need it, in VBA you dont.
as it can only lead to errors for (exceptionally) long names,
leave it out.

also there's no need to test for instrrev.

TheFile = Mid(TheFullPath, InStrRev(TheFullPath, "\") + 1)

assumes xl2000+/Windows



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

?B?RnJhbmsgS2FiZWw=?= wrote in message
:

Hi
just to add to Bob. Depending on your Excel version (Excel 2000+) you
may also have a look at InStrRev

e.g.
i=instrRev(theString,"/")
myVar = Mid(theString, i + 1, 99)

"Bob Phillips" wrote:

You should work from the back then

Dim myVar As String

For i = Len(theString) To 1 Step -1
If Mid(theString, i, 1) = "\" Then
myVar = Mid(theString, i + 1, 99)
Exit For
End If
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Thanks Bob,

Sorry for my expressions being not clear, say:

"c:\Files\Excel8\peter.xls" "c:\Files\Excel888\michelle.xls"
"c:\Files\Excel88\may.xls"

I want to extract the *.xls name in a For Loop.

Thanks & Regards.



"Bob Phillips" wrote:

What do you want, to check that it is there, or its position, or
what?

myVar = Instr(1,"Jeans are popular among the young.","popular")

returns its position assuming it exists

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Hello everybody,

Please kindly tell how to extract the key word "popular " by
VBA function, say Mid, how to:

Dim theString as String
theString = "Jeans are popular among the young."

Thanks & Regards.








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Extract keyword from a string

Hi
agree with you on not needing to add '99'. Just copied Bob's formula
:-)
Also not sure what you mean with 'test for instrrev'. If you mean that
you can combine my two line into one - then o.k. of course you could
do this (just a matter of style IMHO). If not: curious about the
meaning of your statement :-)

--
Regards
Frank Kabel
Frankfurt, Germany


keepITcool wrote:
Why add the 99 as the length of the MID?


in a worksheetfunction you'll need it, in VBA you dont.
as it can only lead to errors for (exceptionally) long names,
leave it out.

also there's no need to test for instrrev.

TheFile = Mid(TheFullPath, InStrRev(TheFullPath, "\") + 1)

assumes xl2000+/Windows



www.XLsupport.com | keepITcool chello nl | amsterdam


?B?RnJhbmsgS2FiZWw=?= wrote in message
:

Hi
just to add to Bob. Depending on your Excel version (Excel 2000+)

you
may also have a look at InStrRev

e.g.
i=instrRev(theString,"/")
myVar = Mid(theString, i + 1, 99)

"Bob Phillips" wrote:

You should work from the back then

Dim myVar As String

For i = Len(theString) To 1 Step -1
If Mid(theString, i, 1) = "\" Then
myVar = Mid(theString, i + 1, 99)
Exit For
End If
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Thanks Bob,

Sorry for my expressions being not clear, say:

"c:\Files\Excel8\peter.xls" "c:\Files\Excel888\michelle.xls"
"c:\Files\Excel88\may.xls"

I want to extract the *.xls name in a For Loop.

Thanks & Regards.



"Bob Phillips" wrote:

What do you want, to check that it is there, or its position, or
what?

myVar = Instr(1,"Jeans are popular among the young.","popular")

returns its position assuming it exists

--

HTH

RP
(remove nothere from the email address if mailing direct)


"myBasic" wrote in message
...
Hello everybody,

Please kindly tell how to extract the key word "popular " by
VBA function, say Mid, how to:

Dim theString as String
theString = "Jeans are popular among the young."

Thanks & Regards.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Extract keyword from a string

Frank,

no meaning other than I must be tired and misread.
cheerz! Jurgen

Frank Kabel wrote in message
:

If not: curious about the meaning of your statement :-)
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Extract keyword from a string

Hi Jurgen
know this feeling <vbg

--
Regards
Frank Kabel
Frankfurt, Germany

"keepITcool" schrieb im Newsbeitrag
...
Frank,

no meaning other than I must be tired and misread.
cheerz! Jurgen

Frank Kabel wrote in message
:

If not: curious about the meaning of your statement :-)


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
extract text from string AskExcel Excel Worksheet Functions 2 October 9th 07 06:54 AM
Extract Data by keyword and export to new Excel sheet Burger Queen Excel Worksheet Functions 1 November 9th 06 09:46 AM
Extract from string mark Excel Discussion (Misc queries) 2 August 8th 06 12:38 PM
Extract sub string sixbeforedawn Excel Worksheet Functions 2 October 24th 05 09:50 AM
extract string dreamer[_17_] Excel Programming 2 June 1st 04 12:50 PM


All times are GMT +1. The time now is 11:42 PM.

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"