Циклы медленны. Матч быстрый, и последняя заполненная ячейка может быть легко расположена снизу вверх.
dim aio as variant, keyCells As Range
with worksheets("sheet1")
aio = application.match("Added Info/Options", .columns(5), 0)
if not iserror(aio) then
set keyCells = .range(.cells(aio+1, "E"), .cells(.rows.count, "D").end(xlup).offset(0, 1))
else
debug.print "Added Info/Options not found"
end if
end with
Я добавил // CHANGE комментарии к коду, где я изменил логику. Вам нужно передать исходный объект того, что вы хотите вернуть, и обновить вложенные ключи для итогов.
computed: {
solutionCost() {
//Looping thru my objects
const total = this.objects.reduce((sum, object) => {
solution_cost_dry = object.amount / object.price;
solution_cost_wet = object.solution_cost[dry] * object.percent;
//CHANGE: add the values to the totals
sum.dry += solution_cost_dry;
sum.wet += solution_cost_wet;
return sum;
}, {dry:0, wet:0}) //CHANGE: Make the initial "sum" be the object with each key with a zero value
//return array with summed values {dry:solution_cost_dry, wet:solution_cost_wet }
return total;
},
}