--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:
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