Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Storing text in an array

I have a simple macro that maps one list of company names against another,
such that small differences are ignored.

For example, American Packaging Corp would return a match (using this macro)
with American Packaging Inc

I want to improve its accuracy, and to do this I want to store 200 "common"
words in an array, then test to see if a word is contained in this array.

For example:
myCommon = {"American", "Company", "Corporation", "Ltd", "Inc"...)

blnCommon = True if a word exists in the array, and blnCommon = False if it
isn't in the array. This is the line of code that isn't working for me.

If I can get help with just this line of code, then I can muddle on from
there.

Thanks
Daniel

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Storing text in an array

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


"Daniel Bonallack" wrote in
message ...
I have a simple macro that maps one list of company names against another,
such that small differences are ignored.

For example, American Packaging Corp would return a match (using this

macro)
with American Packaging Inc

I want to improve its accuracy, and to do this I want to store 200

"common"
words in an array, then test to see if a word is contained in this array.

For example:
myCommon = {"American", "Company", "Corporation", "Ltd", "Inc"...)

blnCommon = True if a word exists in the array, and blnCommon = False if

it
isn't in the array. This is the line of code that isn't working for me.

If I can get help with just this line of code, then I can muddle on from
there.

Thanks
Daniel



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Storing text in an array

Daniel Bonallack wrote:
I have a simple macro that maps one list of company names against another,
such that small differences are ignored.

For example, American Packaging Corp would return a match (using this macro)
with American Packaging Inc

I want to improve its accuracy, and to do this I want to store 200 "common"
words in an array, then test to see if a word is contained in this array.

For example:
myCommon = {"American", "Company", "Corporation", "Ltd", "Inc"...)

blnCommon = True if a word exists in the array, and blnCommon = False if it
isn't in the array. This is the line of code that isn't working for me.

If I can get help with just this line of code, then I can muddle on from
there.

Thanks
Daniel


What's meant by "if a word exists in the array"? Of course a word exists
in the array--200 words exist in the array. Could you give an
illustration of what's being tested against the array?

Alan Beban
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Storing text in an array

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


"Daniel Bonallack" wrote in
message ...
I have a simple macro that maps one list of company names against another,
such that small differences are ignored.

For example, American Packaging Corp would return a match (using this

macro)
with American Packaging Inc

I want to improve its accuracy, and to do this I want to store 200

"common"
words in an array, then test to see if a word is contained in this array.

For example:
myCommon = {"American", "Company", "Corporation", "Ltd", "Inc"...)

blnCommon = True if a word exists in the array, and blnCommon = False if

it
isn't in the array. This is the line of code that isn't working for me.

If I can get help with just this line of code, then I can muddle on from
there.

Thanks
Daniel




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Storing text in an array

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


  #6   Report Post  
Posted to microsoft.public.excel.programming
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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Storing text in an array

Daniel Bonallack wrote:
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


Almost. It puts all the elements of the array into a Dictionary Object,
and then looks in that to see if the sought word is present.

I'm still confused about how it would be used in practice. What's the
point, e.g., of knowing whether "Corporation" is in the
array/dictionary? I have trouble visualizing how that contributes to
improving the accuracy of the matches. That was why I asked for a simple
illustration of that improved accuracy.

Alan Beban
"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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Storing text in an array

I'm not sure yet whether it will help.
I'm trying to map one database of 21,000 company names to another of similar
size. My first mapping macro worked by taking the left x characters, and
decreasing x by 1 until a match was found.
The problem was that Donolley Services International Group (The) would not
get a successful map with The Donolley Services International Group, so I
decided to try mapping on non-common words. I have 200 "common" words to
assign to the array, and I figured I would eliminate these when mapping and
focus only on unique words - in this case "Donolley".
I haven't really moved far on this, but that's the plan. Thanks for your
help, and if you have any suggestions, I'd love to hear them. Oh, and if you
want to see the current version (an xla) just let me know.

Daniel

"Alan Beban" wrote:

Daniel Bonallack wrote:
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


Almost. It puts all the elements of the array into a Dictionary Object,
and then looks in that to see if the sought word is present.

I'm still confused about how it would be used in practice. What's the
point, e.g., of knowing whether "Corporation" is in the
array/dictionary? I have trouble visualizing how that contributes to
improving the accuracy of the matches. That was why I asked for a simple
illustration of that improved accuracy.

Alan Beban
"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


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Storing text in an array

Just another way...

Option Explicit
Sub testme01()

Dim myCommon As String 'string--not variant
Dim myWord As String

myCommon = ".American.Company.Corporation.Ltd.Inc."

myWord = "." & "american" & "."

If InStr(1, myCommon, myWord, vbTextCompare) 0 Then
MsgBox "found it"
Else
MsgBox "not found"
End If

End Sub

The leading/trailing dots are important.



Daniel Bonallack wrote:

I have a simple macro that maps one list of company names against another,
such that small differences are ignored.

For example, American Packaging Corp would return a match (using this macro)
with American Packaging Inc

I want to improve its accuracy, and to do this I want to store 200 "common"
words in an array, then test to see if a word is contained in this array.

For example:
myCommon = {"American", "Company", "Corporation", "Ltd", "Inc"...)

blnCommon = True if a word exists in the array, and blnCommon = False if it
isn't in the array. This is the line of code that isn't working for me.

If I can get help with just this line of code, then I can muddle on from
there.

Thanks
Daniel


--

Dave Peterson
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Storing text in an array

Daniel Bonallack wrote:
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

The assignment to the array variable was just a transient (by habit).
It would have been a little clearer had I just presented

.. . .
Set myCommon = New Dictionary
For Each Elem In Array("American","Company","Corporation","Ltd","In c")
myCommon.Add CStr(Elem), Elem
Next
.. . .

Alan Beban
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
Storing an array in a cell Blue Max Excel Worksheet Functions 9 March 18th 09 12:54 PM
How do I convert a text array to a concatenated text cell? Excel. Vargasjc Excel Worksheet Functions 5 December 20th 06 06:35 PM
storing financial data in array Fred[_19_] Excel Programming 1 September 13th 04 02:23 AM
Excel VBA - Storing text in a variable, and "'Cells' of object _Global failed" engineer[_2_] Excel Programming 3 April 23rd 04 11:35 PM
Storing Variables Todd Huttenstine[_3_] Excel Programming 5 November 27th 03 02:14 AM


All times are GMT +1. The time now is 04:21 AM.

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"