Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2008, 10:05 AM
Registered User
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using VBA to Sort Multiple Columns

Hi there, im using the code below to sort multiple columns when the worksheet is activated. This works, but is incredibly slow in calculating the cells! I was wondering if there was a faster way to do this?

Quote:
quote:Worksheets("lookup").Range("E33:F200").Sort _
        Key1:=Worksheets("Prov_lookup").Range("F33"), order1:=xlDescending, Header:=xlNo
Worksheets("lookup").Range("G33:H200").Sort _
        Key1:=Worksheets("Prov_lookup").Range("H33"), order1:=xlDescending, Header:=xlNo
Worksheets("lookup").Range("I33:J200").Sort _
        Key1:=Worksheets("Prov_lookup").Range("J33"), order1:=xlDescending, Header:=xlNo
Worksheets("lookup").Range("K33:L200").Sort _
        Key1:=Worksheets("Prov_lookup").Range("L33"), order1:=xlDescending, Header:=xlNo
Worksheets("lookup").Range("M33:N200").Sort _
        Key1:=Worksheets("Prov_lookup").Range("N33"), order1:=xlDescending, Header:=xlNo
Worksheets("lookup").Range("O33:P200").Sort _
        Key1:=Worksheets("Prov_lookup").Range("P33"), order1:=xlDescending, Header:=xlNo
Worksheets("lookup").Range("Q33:R200").Sort _
        Key1:=Worksheets("Prov_lookup").Range("R33"), order1:=xlDescending, Header:=xlNo
Worksheets("lookup").Range("S33:T200").Sort _
        Key1:=Worksheets("Prov_lookup").Range("T33"), order1:=xlDescending, Header:=xlNo
Worksheets("lookup").Range("U33:V200").Sort _
        Key1:=Worksheets("Prov_lookup").Range("V33"), order1:=xlDescending, Header:=xlNo
Worksheets("lookup").Range("W33:X200").Sort _
        Key1:=Worksheets("lookup").Range("X33"), order1:=xlDescending, Header:=xlNo
thanks.
 
Old July 30th, 2008, 11:04 AM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

If you aren't already, try turning off calculation and display until the sorts are done:
Application.ScreenUpdating = FALSE
Application.Calculation = xlCalculationManual

Then turning them back on when done:
Application.ScreenUpdating = TRUE
Application.Calculation = xlCalculationAutomatic






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to sort datagrid columns sumith ASP.NET 1.0 and 1.1 Professional 3 February 19th, 2007 01:12 AM
VBA Column Sort Order and numbers Jack1000 BOOK: Access 2003 VBA Programmer's Reference 1 October 5th, 2006 10:53 PM
Sort Columns omrieliav XSLT 0 May 31st, 2006 10:21 AM
sort by two columns in a MySQL DB crmpicco Classic ASP Databases 1 March 18th, 2005 11:51 AM
Dataview Sort: Multiple Databinds between Postback Machete ASP.NET 1.x and 2.0 Application Design 1 December 10th, 2004 10:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.