Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Fastest way to clear contents

Hi. In my workbook I have 8 sheets that are heavily populated with formulas
going from column A through FF and about 150 rows down. All I want to do is
run a macro to clear the contents of a range on all sheets. My code works
perfectly, but it takes 6 minutes to run. I though turning off Autocalc
would help, but it really didn't do much. Why does clearing cells with
formulas in them take so long? If this range was hard coded, it takes
sedonds. Help!? Thanks.........


Sub Clear()

Dim sh As Worksheet
Dim clrarray()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

clrarray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6",
"Sheet7", "Sheet8")

For Each sh In ActiveWorkbook.Worksheets(clrarray)
sh.Range("A5:FF" & Range("b65536").End(xlUp).Row).ClearContents
Next sh
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Fastest way to clear contents

Hi
try
sh.Range("A5:FF200").ClearContents
is this faster?

--
Regards
Frank Kabel
Frankfurt, Germany


Steph wrote:
Hi. In my workbook I have 8 sheets that are heavily populated with
formulas going from column A through FF and about 150 rows down. All
I want to do is run a macro to clear the contents of a range on all
sheets. My code works perfectly, but it takes 6 minutes to run. I
though turning off Autocalc would help, but it really didn't do much.
Why does clearing cells with formulas in them take so long? If this
range was hard coded, it takes sedonds. Help!? Thanks.........


Sub Clear()

Dim sh As Worksheet
Dim clrarray()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

clrarray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5",
"Sheet6", "Sheet7", "Sheet8")

For Each sh In ActiveWorkbook.Worksheets(clrarray)
sh.Range("A5:FF" &
Range("b65536").End(xlUp).Row).ClearContents Next sh
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Fastest way to clear contents

Or try
Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6",
"Sheet7", _
"Sheet8")).Select
Cells.Select
Selection.ClearContents

Mike F
"Steph" wrote in message
...
Hi. In my workbook I have 8 sheets that are heavily populated with

formulas
going from column A through FF and about 150 rows down. All I want to do

is
run a macro to clear the contents of a range on all sheets. My code

works
perfectly, but it takes 6 minutes to run. I though turning off Autocalc
would help, but it really didn't do much. Why does clearing cells with
formulas in them take so long? If this range was hard coded, it takes
sedonds. Help!? Thanks.........


Sub Clear()

Dim sh As Worksheet
Dim clrarray()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

clrarray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5",

"Sheet6",
"Sheet7", "Sheet8")

For Each sh In ActiveWorkbook.Worksheets(clrarray)
sh.Range("A5:FF" & Range("b65536").End(xlUp).Row).ClearContents
Next sh
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Fastest way to clear contents

Steph,
Try:

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Sheets("Sheet1").Select
Range("A5:FF200").Select
Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", _
"Sheet5", "Sheet6", "Sheet7", "Sheet8")).Select

Selection.Clear
Range("A1").Select
Sheets("Sheet1").Select

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True


--
Regards,
Soo Cheon Jheong
Seoul, Korea
_ _
^ąŻ^
--


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
using button to clear contents Charlie Excel Worksheet Functions 2 December 10th 09 02:13 AM
Clear Contents gibbylinks Setting up and Configuration of Excel 5 October 12th 09 05:04 PM
Macro to clear contents and put an X bevchapman Excel Discussion (Misc queries) 3 March 17th 09 07:03 PM
Clear Contents Secret Squirrel Excel Discussion (Misc queries) 1 February 3rd 09 12:37 AM
vb to clear cell contents RichT New Users to Excel 6 June 27th 05 08:26 AM


All times are GMT +1. The time now is 10:03 AM.

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

About Us

"It's about Microsoft Excel"