View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Daniel Bonallack Daniel Bonallack is offline
external usenet poster
 
Posts: 110
Default Storing text in an array

Thanks Alan. Am I right in saying the difference is that your procedure puts
all the elements of the array into an array variable, then you look in that
to see if the word being tested is present?

Daniel

"Alan Beban" wrote:

Daniel Bonallack wrote:
Thanks Tom - this is just what I want (as Alan pointed out, my example was
not very clear, so thanks for returning what I needed).

"Tom Ogilvy" wrote:


Sub Tester2()
Dim blnCommon As Boolean
Dim searchTerm As String
Dim myCommon As Variant
searchTerm = "Company"
myCommon = Array("American", "Company", "Corporation", "Ltd", "Inc")

blnCommon = Not (IsError(Application.Match(searchTerm, myCommon, 0)))
MsgBox blnCommon


End Sub


--
Regards,
Tom Ogilvy


Here is another approach with the same functionality. It requires a
reference to Microsoft Scripting Runtime.

Sub jjj2()
Dim blnCommon As Boolean
Dim searchTerm As String
Dim myCommon As Variant
searchTerm = "Company"
Dim arr, Elem
Dim myCommon As Dictionary
Set myCommon = New Dictionary
arr = Array("American", "Company", "Corporation", "Ltd", "Inc")
For Each Elem In arr
myCommon.Add CStr(Elem), Elem
Next
blnCommon = myCommon.Exists(searchTerm)
MsgBox blnCommon
End Sub

Alan Beban