Deleting Columns Faster

nniedzielski

Active Member
Joined
Jan 8, 2016
Messages
386
Hello all-

I am running a line of code to delete multiple columns of unneeded info, this is what i am running:

Code:
Range("A:B,H:H,J:AD,AG:AK,AN:AX,AZ:BJ,BL:BN").EntireColumn.Delete
Is there a way to run this code and make it go faster? I have a timer on for this line and its taking between 9 and 10 seconds to just run this part, i would like to get that down to 2-3 seconds if possible,

thank you,
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,425
Office Version
365
Platform
Windows
Have you tried turning ScreenUpdating, calculations & events off?
 

nniedzielski

Active Member
Joined
Jan 8, 2016
Messages
386
Code:
Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.Calculation = xlCalculationManual
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,425
Office Version
365
Platform
Windows
In that case I'm not sure there's much more you can do.
How much data do you have on the sheet?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,425
Office Version
365
Platform
Windows
Having seen post#4, try
Code:
Application.EnableEvents = False
as well.
 

nniedzielski

Active Member
Joined
Jan 8, 2016
Messages
386
that didn't really help, and to answer your question in # 5, its ~ 20,000 rows and columns to BN
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,425
Office Version
365
Platform
Windows
For that amount of data it takes me under 1 second
I've tested it on 100,000 rows with columns A:CO and it took about 4 seconds.

Try Ctrl + End where does that take you?
 

nniedzielski

Active Member
Joined
Jan 8, 2016
Messages
386
this is from a document that i export to Excel, and theres some formatting, so i removed the formatting and it took less than a second, so i think i will handle it that way, and then just put formatting back in at the end,
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,425
Office Version
365
Platform
Windows
Glad you found a solution & thanks for the feedback
 

Forum statistics

Threads
1,078,273
Messages
5,339,190
Members
399,288
Latest member
ossa

Some videos you may like

This Week's Hot Topics

Top