I have an Excel table with data about working hours. I want to add a column that calculates the total hours in this week. For example: if I worked 3 days in a single week, the formula has to find every other row that is in the same week and sum the hours worked.

Each table row looks like this:

Date, From (time), To (time), Break (time), Today total (time)

I am thinking of a formula like this: Check the date in the current row and get the calendar week. Now loop through every row and check if the calendar week is equal to the one in the current row. If it is the same, then add the "Today total (time)" to the weekly sum.

Unfortunately I can't find a for each command. Something like =(FOR(A2:A10)(IF....). It would be useful to have something like local variables. I found out that there might be a possibility to write more complex formulas in VBA, but I'm not sure if it is possible to calculate a specific cell value with VBA or it is used for something else.