Hello,
I import my bank data into XL.
It looks something like this:
[TABLE="width: 555"]
<tbody>[TR]
[TD]A1= POS PURCHASE POS25471236 9856320 BLUE HAVEN MA BLUE HAVEN MA[/TD]
[/TR]
[TR]
[TD]A2= POS PURCHASE POS320021025 258413 BLUE HAVEN MA BLUE HAVEN MA[/TD]
[/TR]
[TR]
[TD]A3= CHECK CARD PURCHASE XXXXX5907 MOUNTAIN RESORT XXXXX8411 CO[/TD]
[/TR]
[TR]
[TD]A4= ACH CREDIT XXXXX939X JPMORGAN CHASE EXT TRNSFR[/TD]
[/TR]
[TR]
[TD]A5= CHECK CARD PURCHASE XXXXX1259 DUNKIN #998563 Q35 DALLAS TX[/TD]
[/TR]
[TR]
[TD]A6= CHECK CARD PURCHASE XXXXX1259 FISH MOTORS XXXXX2001 OR[/TD]
[/TR]
[TR]
[TD]A7= CHECK CARD PURCHASE XXXXX1259 MCDONALD'S F2951 DALLAS TX[/TD]
[/TR]
[TR]
[TD]A8= CHECK CARD PURCHASE XXXXX1259 MOUNTAIN RESORT XXXXX4811 CO[/TD]
[/TR]
[TR]
[TD]A9= ONLINE TRANSFER TO XXXXX1259[/TD]
[/TR]
[TR]
[TD]A10= CHECK 985 3663212[/TD]
[/TR]
</tbody>[/TABLE]
My goal is to sort my bank data into categories such as "gas", "food", "gym", etc., by labeling it in the B column next to each line of bank data.
To tell it what to search for and how to label the above data, I have category names in one cell, and the tag-words in an adjacent cell. For example:
A25 = food B25 = mcdonald's, dunkin, antonio's, etc.
A26 = gas B26 = exon, tedesco, shell, etc.
When any one of the words in B25 is found in A5 above for example, it will label that bank data row "food", in the B column next to it.
I have actually figured out how to do that much with the user defined function below. The problem is, I don't really understand the code for the function. I just copied and pasted it and it works great searching for single words. But I need to be able to enter multiple words in my tag words. I would like to be able to search not just for individual words like "mcdonald's", and "dunkin", but also for "burger king" or "antonio's italian pizzaria".
Help?
UDF I am currently using:
<code>Function DupeWord(str1 As String, str2 As String) As String
Dim vArr1
Dim vArr2
Dim vTest
Dim lngCnt As Long
vArr1 = Split(Replace(str1, " ", vbNullString), ",")
vArr2 = Split(Replace(str2, " ", vbNullString), ",")
On Error GoTo strExit
For lngCnt = LBound(vArr1) To UBound(vArr1)
vTest = Application.Match(vArr1(lngCnt), vArr2, 0)
If Not IsError(vTest) Then DupeWord = DupeWord & vArr1(lngCnt) & ", "
Next lngCnt
If Len(DupeWord) > 0 Then
DupeWord = Left$(DupeWord, Len(DupeWord) - 2)
Else
strExit:
DupeWord = "No Matches!"
End If
End Function
</code></pre><code>
Thanks.
</code>
I import my bank data into XL.
It looks something like this:
[TABLE="width: 555"]
<tbody>[TR]
[TD]A1= POS PURCHASE POS25471236 9856320 BLUE HAVEN MA BLUE HAVEN MA[/TD]
[/TR]
[TR]
[TD]A2= POS PURCHASE POS320021025 258413 BLUE HAVEN MA BLUE HAVEN MA[/TD]
[/TR]
[TR]
[TD]A3= CHECK CARD PURCHASE XXXXX5907 MOUNTAIN RESORT XXXXX8411 CO[/TD]
[/TR]
[TR]
[TD]A4= ACH CREDIT XXXXX939X JPMORGAN CHASE EXT TRNSFR[/TD]
[/TR]
[TR]
[TD]A5= CHECK CARD PURCHASE XXXXX1259 DUNKIN #998563 Q35 DALLAS TX[/TD]
[/TR]
[TR]
[TD]A6= CHECK CARD PURCHASE XXXXX1259 FISH MOTORS XXXXX2001 OR[/TD]
[/TR]
[TR]
[TD]A7= CHECK CARD PURCHASE XXXXX1259 MCDONALD'S F2951 DALLAS TX[/TD]
[/TR]
[TR]
[TD]A8= CHECK CARD PURCHASE XXXXX1259 MOUNTAIN RESORT XXXXX4811 CO[/TD]
[/TR]
[TR]
[TD]A9= ONLINE TRANSFER TO XXXXX1259[/TD]
[/TR]
[TR]
[TD]A10= CHECK 985 3663212[/TD]
[/TR]
</tbody>[/TABLE]
My goal is to sort my bank data into categories such as "gas", "food", "gym", etc., by labeling it in the B column next to each line of bank data.
To tell it what to search for and how to label the above data, I have category names in one cell, and the tag-words in an adjacent cell. For example:
A25 = food B25 = mcdonald's, dunkin, antonio's, etc.
A26 = gas B26 = exon, tedesco, shell, etc.
When any one of the words in B25 is found in A5 above for example, it will label that bank data row "food", in the B column next to it.
I have actually figured out how to do that much with the user defined function below. The problem is, I don't really understand the code for the function. I just copied and pasted it and it works great searching for single words. But I need to be able to enter multiple words in my tag words. I would like to be able to search not just for individual words like "mcdonald's", and "dunkin", but also for "burger king" or "antonio's italian pizzaria".
Help?
UDF I am currently using:
<code>Function DupeWord(str1 As String, str2 As String) As String
Dim vArr1
Dim vArr2
Dim vTest
Dim lngCnt As Long
vArr1 = Split(Replace(str1, " ", vbNullString), ",")
vArr2 = Split(Replace(str2, " ", vbNullString), ",")
On Error GoTo strExit
For lngCnt = LBound(vArr1) To UBound(vArr1)
vTest = Application.Match(vArr1(lngCnt), vArr2, 0)
If Not IsError(vTest) Then DupeWord = DupeWord & vArr1(lngCnt) & ", "
Next lngCnt
If Len(DupeWord) > 0 Then
DupeWord = Left$(DupeWord, Len(DupeWord) - 2)
Else
strExit:
DupeWord = "No Matches!"
End If
End Function
</code></pre><code>
Thanks.
</code>