Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I would like to add a macro button that will automatically re-sort a string
of numbers that are calculated at random. Column A are the numbers to which I want to sort while Column B is @rand. Does anyone know how I can accomplish this? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try this macro assigned to a button from the Forms menu bar.
Sub SortIt() Dim Lrow As Long Dim Drng As Range Lrow = Cells(Rows.Count, "A").End(xlUp).Row Set Drng = Range("A1:B" & Lrow) Drng.Sort Key1:=Range("B1"), Order1:=xlAscending End Sub HTH Regards, Howard "momma" wrote in message ... I would like to add a macro button that will automatically re-sort a string of numbers that are calculated at random. Column A are the numbers to which I want to sort while Column B is @rand. Does anyone know how I can accomplish this? |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Or:
select tools--macro--record a macro, when asked for the macro name type: sort under "Store in" select "This workbook" click ok select the range to sort, select data--sort and perform the sort, select tools--macro--stop recording select view--toolbars--control toolbox click the design button (green triangle) click the command button icon click somewhere on your sheet, hold and drag to the right and down to create a button right click in the new button and from the context menu select 'view code' between the lines "private sub" and "end sub" type the name of your macro which was 'sort' close the VBA window on your sheet click the design button click the new button to test it. Mind that the sort range is "fixed" in the macro! So if you need to expand the sort range be sure to reflect the change in the macro. Hans |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Button not bring up Macro I created | Excel Discussion (Misc queries) | |||
Assign a macro to Command Button Object | Excel Discussion (Misc queries) | |||
Macro Button | Excel Discussion (Misc queries) | |||
Attaching a macro to a VB button on a form | Excel Worksheet Functions | |||
Assigning a macro to a "button" | Excel Discussion (Misc queries) |