Macro need to sort Excel 2010 windows XP

Blas

New Member
Joined
May 15, 2011
Messages
4
:) I need a macro that will allow me to manualy select a variable number of rows in a spreadsheet. Macro would then sort on column "B" desending & "C" ascending.
Please help
Blas
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Code:
Sub S()

    Dim i As Variant
    
    i = Application.InputBox("Enter rows amount:", "Input data", 1)
    If i = False Then Exit Sub
    
    Range("B1:B" & i).Sort Key1:=Range("B1"), Order1:=xlDescending
    Range("C1:C" & i).Sort Key1:=Range("C1"), Order1:=xlAscending

End Sub
 
Upvote 0
:) I need a macro that will allow me to manualy select a variable number of rows in a spreadsheet. Macro would then sort on column "B" desending & "C" ascending.
Please help
Blas
Is it this? Test in a copy of your workbook.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> SortMyRows()<br>    <SPAN style="color:#00007F">With</SPAN> Selection.EntireRow<br>        .Sort Key1:=Cells(.Row, 2), Order1:=xlDescending, _<br>            Key2:=Cells(.Row, 3), Order2:=xlAscending, Header:=xlNo<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

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