SubTotal (Exported Data Has Blank Rows)

spyldbrat

Board Regular
Joined
May 5, 2002
Messages
211
Office Version
  1. 365
I need to add subtotals after each grouping in column F. The spreadsheet exports with a blank row between each grouping. I am assuming that the Data/Subtotal feature is not working because of the blank rows. Is there a way I can get the subtotal to show after each grouping in column F? A grand total would be nice, but not needed. The number of rows in each grouping and the amount of locations will vary with each export. I ultimaely plan on using the solution in a macro. I uploaded an image of the spreadsheet
 

Attachments

  • OpenInv.PNG
    OpenInv.PNG
    39.7 KB · Views: 7

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
If you please use XL2BB, anyone helping with a possible solution doesn't have to retype data to illustrate it.
 
Upvote 0
See if this works:

Code:
Sub subtot()
Dim lr As Long, i As Long, st As Double, gt As Double
lr = 2 + Cells(Rows.Count, "F").End(xlUp).Row
i = 8
st = 0
gt = 0
While i < lr
  If Cells(i, "F") <> "" Then
    st = st + Cells(i, "F")
    i = i + 1
  Else
  Cells(i, "F") = st
  Cells(i, "E") = "Sub-Tot"
  gt = gt + st
  st = 0
  i = i + 2
  End If
Wend
Cells(i, "E") = "Grand Total"
Cells(i, "F") = gt
End Sub
 
Upvote 0
Solution
Great. Thanks for the confirmation. Please mark it solved so others don't spend time on it unnecessarily unless they find a better method.
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top