View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Caroline Caroline is offline
external usenet poster
 
Posts: 183
Default Slow subtotal and insert row

It is slow because it calculates while inserting the rows.

call calcmanual before your code
and then calcautomatic after your code
See below

Alternatively why not using a sumif function without any code involved?


Sub CalcAutomatic()
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Calculate

End Sub
Sub CalcManual()

With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

End Sub
--
caroline


"Diana" wrote:

Hi,

I have a worksheet with about 400 rows. Data looks like:

Name calls
Peter 5
John 3
David 9
Jenny 1
Gina 10
Peter 2
Gina 6
Mary 6
David 3

I want the number of calls made by each person.

So what I have done is a sort, then a subtotal, then insert a row after the
subtotal to make it look better.

I find the code for the calculation of the subtotal and insert run very
slowly (takes about a minute. I can see the screen flickering and the rows
being inserted). Is there a way I can make it run faster?

One other question:

In my code I refer to the columns by the letter eg, "J", "K", is there a way
I can tell it to use column headers, eg. Name, calls