shanenavy26
New Member
- Joined
- Sep 26, 2018
- Messages
- 29
Hello,
I currently have an excel sheet to track my monthly expenses. Currently, when I paste the data into the excel sheet, it will look for terms set in a list I made in Col S, and to set the category to whatever is next to it in Col T. After tinkering with it for awhile, I am noticing that it will only look for 1 word at the beginning, and won't work for terms in the middle of a cell or anything with spaces. Example:
What I want:
COSTCO = House
COSTCO Gas = Gas
ABC Restaurant = Fast Food
Currently, it will only look for the first word, and I cannot set words in the middle of cells such as Gas and Restaurant.
Here is the code I currently have, please let me know if i need to provide a better example or explain better, Thank you!
For Each Cl In Intersect(Target, Columns("B"))
If Not Cl.Value = "" Then
s = Split(Cl.Value)(0)
Cat = Application.Index(Range("S2:T100"), Application.Match(s, Range("S2:S100"), 0), 2)
If Not IsError(Cat) Then Cl.Offset(, 1).Value = Cat
End If
Next Cl
Application.EnableEvents = True
I currently have an excel sheet to track my monthly expenses. Currently, when I paste the data into the excel sheet, it will look for terms set in a list I made in Col S, and to set the category to whatever is next to it in Col T. After tinkering with it for awhile, I am noticing that it will only look for 1 word at the beginning, and won't work for terms in the middle of a cell or anything with spaces. Example:
What I want:
COSTCO = House
COSTCO Gas = Gas
ABC Restaurant = Fast Food
Currently, it will only look for the first word, and I cannot set words in the middle of cells such as Gas and Restaurant.
Here is the code I currently have, please let me know if i need to provide a better example or explain better, Thank you!
For Each Cl In Intersect(Target, Columns("B"))
If Not Cl.Value = "" Then
s = Split(Cl.Value)(0)
Cat = Application.Index(Range("S2:T100"), Application.Match(s, Range("S2:S100"), 0), 2)
If Not IsError(Cat) Then Cl.Offset(, 1).Value = Cat
End If
Next Cl
Application.EnableEvents = True