Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Slow VBA code?

I have code which clears a table which was generated the previous run. The
code is:

Range("b20000:o20000").Select
Selection.AutoFill Destination:=Range("b10:o20000"), Type:=xlFillDefault
Range("b10:o20000").Select

I just want to clear the contents and the formats of the previous table
before I build up the next table.

Is there code which can do this faster? It is very slow. Takes about 60
seconds.

Best regards, Gijs
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Slow VBA code?

try either of these:

Sub test()
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
With Range("b20000:o20000")
.Clear
End With
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub

Sub test2()
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Range("b20000:o20000").AutoFill Destination:=Range("b10:o20000"), _
Type:=xlFillDefault
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub


--


Gary


"Gijs Breedveld" wrote in message
...
I have code which clears a table which was generated the previous run. The
code is:

Range("b20000:o20000").Select
Selection.AutoFill Destination:=Range("b10:o20000"), Type:=xlFillDefault
Range("b10:o20000").Select

I just want to clear the contents and the formats of the previous table
before I build up the next table.

Is there code which can do this faster? It is very slow. Takes about 60
seconds.

Best regards, Gijs



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Slow VBA code?

You can get rid of the select

Range("b20000:o20000").AutoFill Destination:=Range("b10:o20000"),
Type:=xlFillDefault
Range("b10:o20000").Select

but I doubt that will make much difference. Also try turning screenupdating
off and setting calculation to manual, and reset after.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Gijs Breedveld" wrote in message
...
I have code which clears a table which was generated the previous run. The
code is:

Range("b20000:o20000").Select
Selection.AutoFill Destination:=Range("b10:o20000"),
Type:=xlFillDefault
Range("b10:o20000").Select

I just want to clear the contents and the formats of the previous table
before I build up the next table.

Is there code which can do this faster? It is very slow. Takes about 60
seconds.

Best regards, Gijs



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Slow VBA code?

Bob,

Thanks .

Best regards,

Gijs

"Bob Phillips" wrote:

You can get rid of the select

Range("b20000:o20000").AutoFill Destination:=Range("b10:o20000"),
Type:=xlFillDefault
Range("b10:o20000").Select

but I doubt that will make much difference. Also try turning screenupdating
off and setting calculation to manual, and reset after.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Gijs Breedveld" wrote in message
...
I have code which clears a table which was generated the previous run. The
code is:

Range("b20000:o20000").Select
Selection.AutoFill Destination:=Range("b10:o20000"),
Type:=xlFillDefault
Range("b10:o20000").Select

I just want to clear the contents and the formats of the previous table
before I build up the next table.

Is there code which can do this faster? It is very slow. Takes about 60
seconds.

Best regards, Gijs




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Slow VBA code?

Gary,

Thanks, this speeds things up.

Best regards,

Gijs

"Gary Keramidas" wrote:

try either of these:

Sub test()
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
With Range("b20000:o20000")
.Clear
End With
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub

Sub test2()
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Range("b20000:o20000").AutoFill Destination:=Range("b10:o20000"), _
Type:=xlFillDefault
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub


--


Gary


"Gijs Breedveld" wrote in message
...
I have code which clears a table which was generated the previous run. The
code is:

Range("b20000:o20000").Select
Selection.AutoFill Destination:=Range("b10:o20000"), Type:=xlFillDefault
Range("b10:o20000").Select

I just want to clear the contents and the formats of the previous table
before I build up the next table.

Is there code which can do this faster? It is very slow. Takes about 60
seconds.

Best regards, Gijs




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Slow code when used as VBA code instead of macro (copying visible columns) [email protected] Excel Programming 3 April 2nd 07 05:26 PM
slow code NickHK Excel Programming 0 December 21st 06 02:32 AM
Can someone help me with this slow code BillReese Excel Programming 7 September 3rd 05 12:34 AM
Slow Code Frank Kabel Excel Programming 1 July 23rd 04 09:28 AM
Is this slow code? Tom Excel Programming 4 March 3rd 04 11:18 PM


All times are GMT +1. The time now is 08:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"