Clear method takes about 5 seconds

YasserKhalil
PlatinumLounger
Posts: 4967
Joined: 31 Aug 2016, 09:02

Clear method takes about 5 seconds

Post by YasserKhalil »

Hello everyone

I am using the following line (but I noticed it took about 5 seconds to clear the cells)

Code: Select all

Worksheets("Sheet1").UsedRange.Cells.Clear
Is there a better way to clear the cells faster?
I tried to disable screen updating but the same problem

User avatar
HansV
Administrator
Posts: 79443
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Clear method takes about 5 seconds

Post by HansV »

You don't need .Cells in that line, but I don't think that will make a difference.

Does it help if you set

Application.Calculation = xlCalculationManual

before, and

Application.Calculation = xlCalculationAutomatic

after clearing?
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4967
Joined: 31 Aug 2016, 09:02

Re: Clear method takes about 5 seconds

Post by YasserKhalil »

Thanks a lot. It doesn't make difference too. It seems it is a problem of my hardware!!

User avatar
HansV
Administrator
Posts: 79443
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Clear method takes about 5 seconds

Post by HansV »

:sad:
Best wishes,
Hans