# Multiple Subtotals

#### bigfoot

##### Active Member
I've found postings on creating subtotals with unknown number of rows. However, I'm searching for help with vba, for a column with multiple groupings, seperated by a blank rows. once a blank row is encountered, total the quantity of the rows prior to the blank, and keep working down. i guess when it encounters multiple blanks, or perhaps a symbol, it would end that column and move on to the next column. i would also like to select the columns to be summed, since that would vary also. any help would be most appreciated. thanks

### Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
is it ok to use the column next to the values?

thanks for response. a column could be inserted, used and deleted afterwards. since there could be 10-15 columns, it could get pretty big. thanks.

Hi. This function creates a subtotal formula in every empty row after a number of values and makes the text bold. If two subsequent empty rows are found, the function stops.

Code:
Sub createsubtotals()

Dim startoflist As Range
Dim m_Column As Integer
Dim m_Row As Integer

m_Column = 1
m_Row = 1

Do
If Cells(m_Row, m_Column).Value <> "" Then
If startoflist Is Nothing Then
Set startoflist = Cells(m_Row, m_Column)
End If
Else
If Not (startoflist Is Nothing) Then
Cells(m_Row, m_Column).Formula = "=SUM(" & startoflist.Address & ":" & Cells(m_Row - 1, m_Column).Address & ")"
Cells(m_Row, m_Column).Font.Bold = True
Set startoflist = Nothing
End If
End If
m_Row = m_Row + 1
Loop While Not (Cells(m_Row, m_Column).Value = "" And Cells(m_Row - 1, m_Column).HasFormula = True)

End Sub

works beautiful. many thanks. couple of questions please.
i noticed that it works on values, but not forumulas. any way to adjust this?
also, any way to input the number of columns sum, instead of one at a time?

works beautiful. many thanks. couple of questions please.
i noticed that it works on values, but not forumulas. any way to adjust this?
also, any way to input the number of columns sum, instead of one at a time?

Replies
9
Views
206
Replies
4
Views
222
Replies
2
Views
174
Replies
1
Views
97
Replies
3
Views
410

1,220,965
Messages
6,157,122
Members
451,399
Latest member
alchavar

### 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