View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ozgrid.com ozgrid.com is offline
external usenet poster
 
Posts: 464
Default Macro for changing number of rows

Dim rRange1 as Range
Set rRange1=Range(Cells(2,3),Cells(Rows.Count,3).End(X lUp))
rRange1.Sort................

Same for your other ranges.
http://www.ozgrid.com/VBA/ExcelRanges.htm


--
Regards
Dave Hawley
www.ozgrid.com

"DyingIsis" wrote in message
...
Hello -

So I'm a little less experienced than I thought.

Below is my table.
Item Rate 1 Rate 2
A 0.60% 0.30%
B 0.50% 0.40%
C 0.50% 0.70%
E 0.30% 0.30%
F 0.20% 0.50%


Below is my Macro:
Sub Ordering_Macro()
'
' Ordering_Macro Macro
'
'
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sor t.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sor t.SortFields.Add
Key:=Range _
("C2:C6"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sor t.SortFields.Add
Key:=Range _
("B2:B6"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sor t
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

I want to be able to apply this macro whether I have 30 records or 3,000
records. I always have the same 3 columns no matter how many records I
have.

Any help would greatly be appreciated.

Thanks for your help in advance.

- DyingIsis