# Complex text and math formula

#### gstevens

##### New Member
Hi everyone,
I have a complex formula I need to figure out that is way over my head. I have a list of rows with text values in one column and corresponding numeric values in another col. What I am trying to do is get subtotals of the numeric data every time the text value changes.
Example:
The first 5 rows the text value is red then the next 8 are blue, the next 10 green etc. Is it possible to have a formula read when the text value changes insert a blank row and give me a subtotal then continuing down the list repeating the process every time the text value changes?

Thank you.

### Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

#### texasalynn

##### Well-known Member
Why not just use the subtotal feature? found in Data --> Subtotal

#### gstevens

##### New Member
Thanks Texasalynn; it’s almost perfect. The numeric data is actually in 2 columns and its giving me the subtotal for each column; not a big deal as I can add these two subtotals together to get one correct subtotal. The only issue is that the sheet has thousands of rows and it’s a timely process to do that.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
This data is from
<o></o>
<TABLE style="MARGIN: auto auto auto 4.65pt; WIDTH: 203pt; BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt" class=MsoNormalTable border=0 cellSpacing=0 cellPadding=0 width=271><TBODY><TR style="HEIGHT: 12pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 46pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8; PADDING-TOP: 0in" vAlign=bottom width=61 noWrap>
\$1,076.00<o></o>

</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 45pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8; PADDING-TOP: 0in" vAlign=bottom width=60 noWrap>
\$0.00<o></o>

</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 56pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8; PADDING-TOP: 0in" vAlign=bottom width=75 noWrap>alab Total<o></o>

</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 56pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8; PADDING-TOP: 0in" vAlign=bottom width=75 noWrap>1,076.00 <o></o>

</TD></TR></TBODY></TABLE>​
<o></o>
These formulas
<o></o>
<TABLE style="MARGIN: auto auto auto 4.65pt; WIDTH: 278.65pt; BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt" class=MsoNormalTable border=0 cellSpacing=0 cellPadding=0 width=372><TBODY><TR style="HEIGHT: 12pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 82.65pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8; PADDING-TOP: 0in" vAlign=bottom width=110 noWrap>;=SUBTOTAL(9,I2:I23)<o></o>

</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 84pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8; PADDING-TOP: 0in" vAlign=bottom width=112 noWrap>=SUBTOTAL(9,J2:J23)<o></o>

</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 56pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8; PADDING-TOP: 0in" vAlign=bottom width=75 noWrap>alab Total<o></o>

</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 56pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8; PADDING-TOP: 0in" vAlign=bottom width=75 noWrap>=+J24+I24 <o></o>

</TD></TR></TBODY></TABLE>
<o></o>
Last question; is there a way to avoid manually adding these two columns and getting one subtotal?
<o></o>

#### texasalynn

##### Well-known Member
I would suggest that you put in the column to add the two columns, then do the subtotal on that.

#### gstevens

##### New Member
That works.

Thank again.

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,167,991
Messages
5,856,684
Members
431,828
Latest member
kARTIK12345

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back