RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 801
- Office Version
- 365
- Platform
- Windows
Hi all, can't even figure out how to phrase this in Google or ChatGPT to get something that is nice and clean.
I have a sheet where in column J, there are costs, and sub-totals for those costs.
Each subtotal is a named range, for instance:
"DirectCostSum" is J23
"IndirectCostSum" is J31
What I'd like to do is for IndirectCostSum cell value to be a sum of J24:J30.
These subtotals are dynamically placed based on how many products I am summing, so the gap between the named ranges I want to sum is always changing.
What I'm after is a nice, one line chunk of code which will be like..
That's the best way I can describe it lol. Hopefully that makes sense.
I have a sheet where in column J, there are costs, and sub-totals for those costs.
Each subtotal is a named range, for instance:
"DirectCostSum" is J23
"IndirectCostSum" is J31
What I'd like to do is for IndirectCostSum cell value to be a sum of J24:J30.
These subtotals are dynamically placed based on how many products I am summing, so the gap between the named ranges I want to sum is always changing.
What I'm after is a nice, one line chunk of code which will be like..
VBA Code:
range("IndirectCostSum").formular1c1 = "=SUM( [DirectCostSum + 1],[IndirectCostSum -1]),
That's the best way I can describe it lol. Hopefully that makes sense.