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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,496
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,496
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,496
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,496
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,496
Office Version
365
Platform
Windows
Glad you found a solution & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,095,230
Messages
5,443,233
Members
405,219
Latest member
CraneS

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top