I try to get my finances together and for that downloaded my data from the local bank as excel. As it is pretty wild (and some years), I want display the data summed up for what I use my money for, as "food", "rent" and stuff. For that I want to go through all the rows and check if a certain cell in the row contains any known word, where I know where to put it in my expenses.
For example: if there is the name of a restaurant in a certain cell, it is a food expense, but the same if it is walmart for example.
I came up with something like:
Dim food() As String
food(0) = "Nespresso"
food(1) = "Spar"
food(2) = "Billa"
Dim SrchRng As Range, cel As Range
Set SrchRng = Range("I3:I9")
For Each cel In SrchRng
If InStr(1, cel.Value, food(0)) Or InStr(1, cel.Value, food(1)) Or InStr(1, cel.Value, food(2)) > 0 Then
cel.Offset(0, 3).Value = "Essen/Trinken"
Else
cel.Offset(0, 3).Value = "-"
End If
Next cel
But there are some problems with the code:
- if all the variables are in a array, there certanly is a way to not be specific and go through array(0), (1), ... but I don't know how.
- to make it more "editable" and convenient, I don't want to hardcode it, but have a 2nd sheet which displays "food" in A1 and on A2-n the different variables for food(0)-food(n-2) should be used.
- using the range to a fixed amount also is not a good way how to make sure to work on any given data, it would be best to check for the last row with data first
I already found ways to come to answer point 3 tho.
Everything would help. Thanks in advice :)
I'm not so sure if I understand you correctly. Anyway....
The expected result after running the macro is something like below :

rgExp is the range of column A in Sheet2.
rgData is the range of column i in Sheet1.
The loop is not within the rgData but rgExp.
Within this loop, it loop with find/find-next method to unite the range of the found cell (which value contains the looped cell value in rgExp) as rgU variable. Then it fill the rgU.offset(0,3) with the looped cell.offset(0,1) value.
If in Sheet2 the table you want is something like this :

Then set the rgExp like this
and after the find-next loop done, the filling for the rgU.offset(0,3) is like this :