Auto Select - Drop Down Option

shanenavy26

New Member
Joined
Sep 26, 2018
Messages
29
Here is the Sample that I will be referencing: https://www.dropbox.com/s/qsnzojulgipugma/Test.xlsm?dl=0

In this financial planner, I have data in sheet one that gets moved over to sheet 2. When this happens, it auto updates the text to remove all the repeating data. (card number). I have made rest of the process automatic except for needing to use the drop down list I created and choose a category for each expense. You can see that in the C- Column.

**Please note, you have to copy and "PasteAsValue" Otherwise the categories don't work. (unless you know a fix for that too).**

My question is: There are many expenses reoccurring every month, such as the same restaurant, or same store, and bills.
how can I get specific strings to auto choose a category. Such as in the Sample, I made "TACOBELL" and "WALMART". When I paste over the expenses, id like a VBA or some other method to be able to find taco bell, and auto choose the Fast Food category, and for Walmart to auto choose the store category.

I would also like the ability to add and edit these strings so I can filter more of these expenses later. Thank you!!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
If you create a lookup table such as this


Excel 2013/2016
GH
3WALMARTStores
4TACOBELLFast Food
5ExpenseBills
6CreditIncome
Jan Auto


How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim Cl As Range
   Dim Cat As Variant
   Dim s As String
   If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
   Application.EnableEvents = False
   Target.Replace "ACH Transaction - ", "", xlPart, , False, , False, False
   Target.Replace "POS Debit - Visa Check Card XXXX - ", "", xlPart, , False, , False, False
   For Each Cl In Intersect(Target, Columns("B"))
      s = Split(Cl.Value)(0)
      Cat = Application.Index(Range("[COLOR=#ff0000]G3:H6[/COLOR]"), Application.Match(s, Range("[COLOR=#ff0000]G3:G6[/COLOR]"), 0), 2)
      If Not IsError(Cat) Then Cl.Offset(, 1).Value = Cat
   Next Cl
   Application.EnableEvents = True
End Sub
Change ranges in red to suit
 
Upvote 0
Thanks Fluffy. Will this work for generic things as well? Such as this transaction:
FARM FRESH 543 CITY ST
Will it still work if I put just "Farm Fresh" in G? or does it need to be word for word.

<colgroup><col></colgroup><tbody>
</tbody>
 
Upvote 0
At the moment it is matching on the first word, so as long as you only have one transaction type that starts with "Farm", you can use that.
 
Upvote 0
Actually now that I look at it. I believe the Auto Rename and Auto Category are canceling eachother out. Maybe a delay between the two would fix it?
 
Last edited:
Upvote 0
The first part isn't working as instead of having values like "POS Debit - Visa Check Card XXXX", the X's are now numbers.
The secnond part wasn't working as you had an error in the Index/Match function.
Try
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim Cl As Range
   Dim Cat As Variant
   Dim s As String
   If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
   Application.EnableEvents = False
   Target.Replace "ACH Transaction - ", "", xlPart, , False, , False, False
   Target.Replace "POS Debit - Visa Check Card [COLOR=#ff0000]????[/COLOR] - ", "", xlPart, , False, , False, False
   For Each Cl In Intersect(Target, Columns("B"))
      [COLOR=#0000ff]If Not Cl.Value = "" Then[/COLOR]
         s = Split(Cl.Value)(0)
         Cat = Application.Index(Range("U2:V9"), Application.Match(s, Range("[COLOR=#ff0000]U2:U9[/COLOR]"), 0), 2)
         If Not IsError(Cat) Then Cl.Offset(, 1).Value = Cat
      [COLOR=#0000ff]End If[/COLOR]
   Next Cl
   Application.EnableEvents = True
End Sub
I've also added the part in blue, incase there is a blank in Col B.
Also with that data your lookup table needs to be like


Excel 2013/2016
UV
1ReferenceCatagory
2FARMGroceries
3AMAZONMisc
4NAVYStores
5COXBills
6USAABills
7BelvidereBills
8WAL-MARTStores
97-ELEVENGroceries
March
 
Upvote 0
I changed the table to how you put it.

Then copied over the code and added a second replace line like this:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cl As Range
Dim Cat As Variant
Dim s As String
If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Replace "ACH Transaction - ", "", xlPart, , False, , False, False
Target.Replace "POS Debit - Visa Check Card 1111 - ", "", xlPart, , False, , False, False
Target.Replace "POS Debit - Visa Check Card 0000 - ", "", xlPart, , False, , False, False
For Each Cl In Intersect(Target, Columns("B"))
If Not Cl.Value = "" Then
s = Split(Cl.Value)(0)
Cat = Application.Index(Range("U2:V9"), Application.Match(s, Range("U2:U9"), 0), 2)
If Not IsError(Cat) Then Cl.Offset(, 1).Value = Cat
End If
Next Cl
Application.EnableEvents = True
End Sub

It works to auto replace the test AND categorize. However it is also making a bunch of other things "groceries".

3/30/20187-ELEVEN CITY STGroceries1.73
3/29/2018EZPASSST SERVICE 877-723423423Groceries20.00
3/29/2018AMAZON MKTPLACE PM AMZNCOM BMisc0.57
3/28/2018Deposit - DFAS-CLEVELANDGroceries1603.18
3/27/2018WARRIORS MANGOLIAN CITY SGroceries27.3
3/27/2018FARM FRESH 246 CITY STGroceries10.51
3/26/2018FARM FRESH 246 CITY STGroceries214.03
3/26/2018AMAZON MKTPLACE PM AMZNCOM BMisc37.96
3/26/2018FARM FRESH 246 CITY STGroceries17.81
3/23/20187-ELEVEN CITY STGroceries14.72
3/22/2018BEST BUY PAYMENT 9817237198Groceries27.00
3/22/2018LAUNDRY CARD ADD V HTTPS WWWGroceries20.00

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
I don't get that, I get


Excel 2013/2016
ABCD
330-Mar-187-ELEVEN CITY STGroceries1.73
429-Mar-18EZPASSST SERVICE 877-72342342320
529-Mar-18AMAZON MKTPLACE PM AMZNCOM BMisc0.57
628-Mar-18Deposit - DFAS-CLEVELAND
727-Mar-18WARRIORS MANGOLIAN CITY S27.3
827-Mar-18FARM FRESH 246 CITY STGroceries10.51
926-Mar-18FARM FRESH 246 CITY STGroceries214.03
1026-Mar-18AMAZON MKTPLACE PM AMZNCOM BMisc37.96
1126-Mar-18FARM FRESH 246 CITY STGroceries17.81
1223-Mar-187-ELEVEN CITY STGroceries14.72
1322-Mar-18BEST BUY PAYMENT 981723719827
1422-Mar-18LAUNDRY CARD ADD V HTTPS WWW20
March


Have you added anything else to the lookup table?
 
Upvote 0

Forum statistics

Threads
1,216,759
Messages
6,132,556
Members
449,735
Latest member
Gary_M

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top