ifeelalone
New Member
- Joined
- Mar 6, 2017
- Messages
- 31
I am trying to loop to apply subtotals through all of my sheets except "Summary" and "Reference_list".
But I am getting an error "Run-time error 1004 : This can't be applied to the selected range. Select a single cell in a range and try again"
Notes:
1. the table starts on A3
2. apply subtotal in Column J and Column M
3. at each change in Column A
I am using this code:
Here's a sample of a sheet:
Excel 2016 (Windows) 32 bit
<tbody>
</tbody>
<tbody>
</tbody>
But I am getting an error "Run-time error 1004 : This can't be applied to the selected range. Select a single cell in a range and try again"
Notes:
1. the table starts on A3
2. apply subtotal in Column J and Column M
3. at each change in Column A
I am using this code:
Sub SubTotals() Dim LastRow As Long
Dim wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
If wks.Name <> "Summary" And wks.Name <> "Reference_List" Then
With wks
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
.Range("A3:S" & LastRow).Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(10, 13), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
End With
End If
Next
End Sub
Here's a sample of a sheet:
Excel 2016 (Windows) 32 bit
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Title of this sheet here | ||||||||||||||||||
2 | Deposits | Amount Posted | |||||||||||||||||
3 | Month_Name | ColumnB | ColumnC | ColumnD | ColumnE | ColumnF | ColumnG | ColumnH | ColumnI | ColumnJ | ColumnK | ColumnL | ColumnM | ColumnM | ColumnO | ColumnP | ColumnQ | ColumnR | ColumnS |
4 | January | 01/05/16 | Alvin Empleo | 1335 | 1,222.00 | 1,222.00 | 1,222.00 | 1,222.00 | 1/12/2016 | 315129462 | |||||||||
5 | January | 01/05/16 | Alvin Empleo | 1335 | 1,222.00 | 1,222.00 | 1,222.00 | 1,222.00 | 1/12/2016 | 315129462 | |||||||||
6 | January | 01/05/16 | Alvin Empleo | 1335 | 1,222.00 | 1,222.00 | 1,222.00 | 1,222.00 | 1/12/2016 | 315129462 |
<tbody>
</tbody>
Sheet: Alvin Empleo |
<tbody>
</tbody>
Last edited: