Thursday, April 5, 2012

In String for Excel

For some reason, Excel doesn't have a built-in function to query whether a string contains a specified second string. Luckily, the joys of VB allow us to do so.

In Excel, under the Developer tab, click "Visual Basic." In the left-hand pane, right-click "VBAProject ()" > Insert > Module. Paste the below snippet into the main pane and save. Now you can call this function into Excel just as you would any other.

~~~
Function InstrE(start As Integer, examine As String, lookFor As String) As Integer

InstrE = InStr(start, examine, lookFor)

End Function
~~~

No comments:

Post a Comment