Forum Discussion
Hannah365
Feb 10, 2022Copper Contributor
Macro for adding columns with variable rows
Hi! I am trying to create a macro that will subtotal columns I and L where column B contains the word "summary". is this possible?!?!?
HansVogelaar
Feb 10, 2022MVP
Perhaps
=SUMIF(B2:B100, "summary", I2:I100)+SUMIF(B2:B100, "summary", L2:L100)
Adjust the ranges as needed.
- Hannah365Feb 10, 2022Copper Contributor
Hmmm it did not work for some reason.
- Hannah365Feb 10, 2022Copper ContributorAssuming i enter this formula in the conditional formatting ?
- HansVogelaarFeb 10, 2022MVP
You mentioned subtotal in the first post, not conditional formatting!
Select columns I and L.
I will assume that the active cell in the selection is in row 1.
On the Home tab of the ribbon, select Conditional Formatting > New Rule...
Select 'Use a formula to determine which cells to format'.
Enter the formula
=$B1="summary"
Click Format...
Activate the Fill tab.
Select a color.
Click OK, then click OK again.