ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   is there any substring function in macro? (https://www.excelbanter.com/excel-programming/353775-there-any-substring-function-macro.html)

ashishprem[_5_]

is there any substring function in macro?
 

Hi All,
I am new to macro. May be its a sily question but still. I have a
string "B&F OFA 12". I wanna to know whether OFA is present in the
string or not. I mean substring...
Please help me out..
Thanks n Regards,
Ashish


--
ashishprem
------------------------------------------------------------------------
ashishprem's Profile: http://www.excelforum.com/member.php...o&userid=31485
View this thread: http://www.excelforum.com/showthread...hreadid=514302


Norman Jones

is there any substring function in macro?
 
Hi Ashishprem,

Look at the Instr function in VBA help.

If InStr(1, sStr, sStr2, vbTextCompare) 0 Then _
MsgBox "Substring " & sStr2 & " found in " & sStr


---
Regards,
Norman



"ashishprem" wrote
in message ...

Hi All,
I am new to macro. May be its a sily question but still. I have a
string "B&F OFA 12". I wanna to know whether OFA is present in the
string or not. I mean substring...
Please help me out..
Thanks n Regards,
Ashish


--
ashishprem
------------------------------------------------------------------------
ashishprem's Profile:
http://www.excelforum.com/member.php...o&userid=31485
View this thread: http://www.excelforum.com/showthread...hreadid=514302




Patrick Molloy[_2_]

is there any substring function in macro?
 
use INSTR() this returns a 0 if the substring doesn't exist or the number of
the letter in the string where it occurs. You could also use the LIKE method

if INSTR(text, thisbit) 0 Then
msgbox thisbit & " is in " & text
Else
msgbox thisbit & " is not in " & text
End if

if text LIKE "*" & thisbit & "*" Then
msgbox thisbit & " is in " & text
Else
msgbox thisbit & " is not in " & text
End if




"ashishprem" wrote:


Hi All,
I am new to macro. May be its a sily question but still. I have a
string "B&F OFA 12". I wanna to know whether OFA is present in the
string or not. I mean substring...
Please help me out..
Thanks n Regards,
Ashish


--
ashishprem
------------------------------------------------------------------------
ashishprem's Profile: http://www.excelforum.com/member.php...o&userid=31485
View this thread: http://www.excelforum.com/showthread...hreadid=514302




All times are GMT +1. The time now is 05:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com