Friday 25 October 2013

Excel Macro to find the sub string


Sub findSubString()
'Excel macro to check if one string exists in another string

'We can use below macro code in excel to check if one string exists in another string
'if substring is found, InStr function will return the position where the match is found

x = InStr(1, "Salman Khan", "khan", vbTextCompare)
MsgBox x

'Above macro code will print 8 as "khan" appears in "salman khan" at 8th position
'Last parameter in the function instr is used to specify whether comparison is case-sensitive or not.
'vbtextcompare = Case insensitive comparison
'vbBinaryCompare  = case sensitive comparison

End Sub


What do you think on above excel macro topic? Please provide your input, comments, questions on excel macro. I will try to reply as soon as possible. I value your opinion on Excel Macros.

No comments:

Post a Comment

Popular Posts

Search This Blog