VBA Speed Sort ?

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
784
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I could of course record a macro but I have the need for speed.

How can I speed up my sorting job via written code versus a scripted code?

I'm using Excel 2013 & I want to quicken my sort criteria:
-expanded selection Columns C:2 to Column V:573
-not in deleting duplicates
-by Column G from smallest to highest

Many thanks in advance.

R/
Pin

:confused:
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Arithos

Well-known Member
Joined
Aug 14, 2014
Messages
598
Hi All,

I could of course record a macro but I have the need for speed.

How can I speed up my sorting job via written code versus a scripted code?

I'm using Excel 2013 & I want to quicken my sort criteria:
-expanded selection Columns C:2 to Column V:573
-not in deleting duplicates
-by Column G from smallest to highest

Many thanks in advance.

R/
Pin

:confused:

It should not be that slow tho, should it? That is usually not the part im worried about going to "slow".

Do you however need the range C2:V573 beeing dynamic? or will it always be this selection?
 

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
784
Office Version
  1. 365
Platform
  1. Windows
Hi Sturla,

It will always be this selection. I just would like to see if there was a written VBA to accomplish this task.

Can you provide a code for this?

Thanks,
Pin
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,833
Office Version
  1. 2010
Platform
  1. Windows
Code:
Range("C2:V753").Sort Key1:=Range("G2")
 

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
784
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Wow shg,

I'm going to try this out ASAP! Thanks, I'm under the assumption that this will sort from 'smallest to largest'.

Many Thanks,
Pin
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,833
Office Version
  1. 2010
Platform
  1. Windows
You're welcome.
 

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
784
Office Version
  1. 365
Platform
  1. Windows
Hey 'shg',

I know its been awhile, but do you also know how to also sort by 'A' to 'Z'?

If 'Range("C2:V753").Sort Key1:=Range("G2")' sorts by 'smallest' to 'largest'?

Many thanks,

Pin
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,015
Messages
5,834,939
Members
430,327
Latest member
Mr_Himalayan778

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top