Sort Alphabetically In a Macro

--ndn.diva--

New Member
Joined
Jun 23, 2008
Messages
12
Hi.
I'm trying to write a macro to sort data in a table alphabetically but the macro isn't working (either i get an error message, or the macro runs without sorting the data).
Can someone please tell me what I am doing wrong?
Thanks!!

Macro Code:
Code:
'   Month = January
    If (Range("month") = "1") Then
    Sheets("ra1").Activate
 
'     Avg Size Per Acct Sold (excl Equiv)
    ActiveSheet.Columns("a:c").Select
    Selection.autofilter
    Selection.autofilter field:=1, Criteria1:="jan"
'   filter table: month=january
    Sheets("ra accts").Activate
    ActiveSheet.Range("c8:j8").Select
    Selection.Copy
'   copy january data
    Sheets("ra1").Activate
    ActiveSheet.Range("b2").Select
    Selection.PasteSpecial Paste:=xlValues, operation:=xlNone, skipblanks _
        :=False, Transpose:=True
'   transpose data into table
    ActiveSheet.Range("A:D").Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
'   sort table in ascending order
'   formulas are calculated automatically
    Sheets("ra accts").Activate
    End If
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,214,515
Messages
6,119,972
Members
448,933
Latest member
Bluedbw

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