Increase speed of macro over 20 worksheets

ChaseCarlstrom

New Member
Joined
Feb 18, 2011
Messages
2
Hi,

I am hoping to get some advice on how to get my macro to run faster. I am using the macro listed below to .clearcontents of a cell range on multiple sheets.

Sub ClearBook()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim Cell As Range
For Each Cell In Range("G12:AU2310")
If Not Cell.HasFormula Then
If IsNumeric(Cell.Value) Then
Cell.ClearContents
End If
End If
Next Cell
Application.Calculation = xlCalculationAutomatic
End Sub

This worked quickly on a single worksheet, but when I use:

Sheets("Total").Select
Application.Run "'W1.5 Trial v7 - CC.xls'!ClearBook"

over 20 worksheets, it takes between 6 - 10 minutes to complete.

Note: I also tried to use:Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.ClearContents, as a different way to clear cells, but it bombed.

My real question is how do I get the marco that works for me to run faster?

Thanks,

Chase
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try

Code:
Sub ClearBook()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Range("G12:AU2310").SpecialCells(xlCellTypeConstants, xlNumbers).ClearContents
Application.Calculation = xlCalculationAutomatic
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,548
Members
452,927
Latest member
rows and columns

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