Script is really slow and sometimes crashes
Solved/Closed
josh07429
Posts
14
Registration date
Friday June 23, 2017
Status
Member
Last seen
November 20, 2017
-
Updated on Jul 6, 2017 at 06:05 PM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - Jul 7, 2017 at 11:42 PM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - Jul 7, 2017 at 11:42 PM
Related:
- Anu script manager 7.0 free download filehippo
- Kmspico free download - Download - Other
- Football manager 2024 free download pc - Download - Simulation
- Fc 24 free download - Download - Sports
- Gta 5 download apk pc - Download - Action and adventure
- Minecraft bedrock free download pc - Download - Sandbox
2 responses
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Updated on Jul 7, 2017 at 07:26 AM
Updated on Jul 7, 2017 at 07:26 AM
Hello Josh,
Here is another loop type construct that may be a little quicker:-
or you can use Autofilter which is quicker again on a large data set:-
.......and following is a "sleeker" version of using the Autofilter:-
Of course you can change Sheet 1 to ActiveSheet if you prefer.
I hope that this helps.
Cheerio,
vcoolio.
Here is another loop type construct that may be a little quicker:-
Sub DeleteThings() Dim lr As Long Dim c As Range lr = Range("H" & Rows.Count).End(xlUp).Row Application.ScreenUpdating = False For Each c In Range("J2:J" & lr) If c.Value = "0" Then c.Offset(, -2).ClearContents End If Next c Application.ScreenUpdating = True End Sub
or you can use Autofilter which is quicker again on a large data set:-
Sub DeleteThings2() Dim lr As Long Application.ScreenUpdating = False Range("J1", Range("J" & Rows.Count).End(xlUp)).AutoFilter 1, 0, , , 7 lr = Range("H" & Rows.Count).End(xlUp).Row If lr > 1 Then Range("H2", Range("H" & Rows.Count).End(xlUp)).ClearContents End If [J1].AutoFilter Application.ScreenUpdating = True End Sub
.......and following is a "sleeker" version of using the Autofilter:-
Sub DeleteThings3() Application.ScreenUpdating = False With Sheet1.Range("J1", Range("J" & Rows.Count).End(xlUp)) .AutoFilter 1, 0 .Offset(1, -2).ClearContents .AutoFilter End With Application.ScreenUpdating = True End Sub
Of course you can change Sheet 1 to ActiveSheet if you prefer.
I hope that this helps.
Cheerio,
vcoolio.
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jul 7, 2017 at 07:23 PM
Jul 7, 2017 at 07:23 PM
Hi Josh,
You're welcome. Glad that I was able to help again.
I'd probably go with the third option especially if your data set is expected to grow larger.
Keep the other two up your sleeve as they can be adapted for other scenarios.
Cheerio,
vcoolio.
You're welcome. Glad that I was able to help again.
I'd probably go with the third option especially if your data set is expected to grow larger.
Keep the other two up your sleeve as they can be adapted for other scenarios.
Cheerio,
vcoolio.
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
>
Blocked Profile
Jul 7, 2017 at 11:42 PM
Jul 7, 2017 at 11:42 PM
Thanks Mark.
Just following your edict of having fun!
Just following your edict of having fun!
Jul 7, 2017 at 06:57 PM
all of them works now my problem is what to use lol