Thank You very machHello Valdas,
Thank you for reaching out to our forum for assistance. Unfortunately, we weren't able to sum up all the cells in a row based on the criteria you provided. However, I have created a custom function called "Sum_with_Condition" using VBA code to help you achieve your desired results. To guide you better, I have attached a sample file in .xlsm format that illustrates how to use this function. Additionally, I have also provided a screenshot to help you better understand how to use this function.
View attachment 1029
Sum_with_Condition(first_cell, last_cell, criteria)
first_cell: This is the starting cell in the row from which you want to begin summing the values.
last_cell: This is the ending cell in the row where you want to stop summing the values.
criteria: This is a string that represents the condition you want to check in the cells to the right of each value.
Note: Unlike the default functions in Excel, this function will not calculate the value automatically whenever the worksheet gets changed by the user. So you have to manually trigger the recalculation of this custom function by going to the cells where you have used this function and re-entering the formula.
Please let me know if you have any further questions or issues.
PS: Please make sure to enable macro before using the function.