View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
gary gary is offline
external usenet poster
 
Posts: 80
Default Inserting subtotals very slow

On Jan 24, 10:25*pm, GS wrote:
gary presented the following explanation :

The parcels, types and amounts were imported into the Excel 2007
spreadsheet from a text file.
Now, I need to get each the subtotals of each parcel's tax, penalty
and cost amounts
I began the subtotaling process over 3 hours ago. *At the bottom of
the spreadsheet, the green "Inserting Subtotals" "progress bar" is
only half way across the bar. *At that rate, it'll take another 4
hours or so before all the subtotals have been inserted into the
spreasheet.


Ok, that's more helpful! How is the data being imported? If by VBA then
the subtotals can be added fairly easily in that process. If using the
Import Wizard OR just opening a CSV, you can add the subtotals just as
easily by a macro. Assuming the latter...

Sub InsertSubtotals()
* Dim lTargetCol As Long, lRows As Long
* With ActiveSheet.UsedRange
* * lTargetCol = .Columns.Count + 1: lRows = .Rows.Count - 1
* End With
* With Cells(2, lTargetCol).Resize(lRows)
* * .NumberFormat = "0.00": .Formula = "=SUM($C2:$E2)": .Value = .Value
* End With
End Sub

..where colF is empty to receive the subtotals. If you don't want the
formulas converted to constant values then omit the last part assigning
the .Value to the range.

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Hi Garry,

Why does the DATA/SUBTOTAL method take so long? (So far, it's taken
5 1/2 hrs and the green "Inserting Subtotals" "progress bar" is only
about 3/4 of the way across the bar).