Deleting Columns Faster

nniedzielski

Active Member
Joined
Jan 8, 2016
Messages
481
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,
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Fluff

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

nniedzielski

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

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,785
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
38,785
Office Version
365
Platform
Windows
Having seen post#4, try
Code:
Application.EnableEvents = False
as well.
 

nniedzielski

Active Member
Joined
Jan 8, 2016
Messages
481
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
38,785
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
481
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
38,785
Office Version
365
Platform
Windows
Glad you found a solution & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,095,794
Messages
5,446,527
Members
405,406
Latest member
tuxy

This Week's Hot Topics

Top