Hi all,
I'm new to VBA and this forum and was wondering if you could advise me on how to correctly use a wildcard in VLOOKUP (or an alternative approach to the below - suggestions welcome).
I have a list of transaction descriptions in Column C. What I am trying to do is categorise these transactions based on a number of keywords. Where i am stuck is that the below code looks up the whole value of Cells in Column C and not just whether the cell CONTAINS the key word. Any ideas?
DATA EXAMPLE
COLUMN C (DESCRIPTION): "Bank MTG Mort. payment"
COLUMN G (WHERE RETURN VAL. SHOULD GO): MORTGAGE
COLUMN H (KEYWORD TO SEE IF CONTAINED IN COLUMN C'S CELL): MTG
COLUMN I (RETURN VALUE IF "MTG" EXISTS IN COLUMN C'S CELL): MORTGAGE
Sub Categ()
On Error Resume Next
Dim Txn_Row As Long
Dim Txn_Clm As Long
Table1 = Sheet1.Range("C465:C480") ' Transaction Description Column
Table2 = Sheet1.Range("H465:I466") ' Category Lookup Range
Txn_Row = Sheet1.Range("G465").Row ' Start populating Category
Txn_Clm = Sheet1.Range("G465").Column
For Each Txn In Table1
Sheet1.Cells(Txn_Row, Txn_Clm) = Application.WorksheetFunction.VLookup(Txn, Table2, 2, False)
Txn_Row = Txn_Row + 1
Next Txn
MsgBox "Finished"
End Sub
Bookmarks