VBA to sort by alphabetical order but not "Totals"

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
882
Hi all, I would like to write a VBA code so that, to sort by alphabetical order, by “CATEGORY” heading, beginning from row “A5” but excluding the last row which is the “Totals” row. I present below the original data and the expected result.
Thanking you in advance​

ORIGINAL DATA
A
B
C
D
E
F
G
H
4

CATEGORY
JAN COST
FEB COST
MAR COST
APR COST
MAY COST
JUN COST
JUL COST
5
SOFT DRINKS
1,501.00
1,756.00
1,874.00
2,105.00
2,325.00
3,128.00
4,258.00
6
SPIRITS & ALCOHOLICS
855.00
910.00
1,241.00
1,105.00
1,855.00
1,458.00
1,785.00
7

CEREALS & BAKERIES
457.00
589.00
659.00
478.00
558.00
378.00
459.00
8
HOT BEVERAGES
455.00
357.00
378.00
310.00
278.00
290.00
283.00
9
APERITIFS
125.00
220.00
142.00
238.00
345.00
248.00
275.00
10

3,393.00
3,832.00
4,294.00
4,236.00
5,361.00
5,502.00
7,060.00

<tbody>
</tbody>


EXPECTED RESULT
A
B
C
D
E
F
G
H
4

CATEGORY
JAN COST
FEB COST
MAR COST
APR COST
MAY COST
JUN COST
JUL COST
5
APERITIFS
125.00
220.00
142.00
238.00
345.00
248.00
275.00
6
HOT BEVERAGES
455.00
357.00
378.00
310.00
278.00
290.00
283.00
7

CEREALS & BAKERIES
457.00
589.00
659.00
478.00
558.00
378.00
459.00
8
SOFT DRINKS
1,501.00
1,756.00
1,874.00
2,105.00
2,325.00
3,128.00
4,258.00
9
SPIRITS & ALCOHOLICS
855.00
910.00
1,241.00
1,105.00
1,855.00
1,458.00
1,785.00
10

3,393.00
3,832.00
4,294.00
4,236.00
5,361.00
5,502.00
7,060.00

<tbody>
</tbody>
 
Last edited:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
If you need a macro for that you can easily record one. It's just a normal sort
 
Upvote 0
Is it okay that, will not sort the last one which row which contains the "Totals"? How can i exclude the row with "Totals"?
 
Upvote 0
Because Col A is blank on the totals row, it will automatically be at the bottom
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

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
Back
Top