ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sort Macro (https://www.excelbanter.com/excel-discussion-misc-queries/228643-sort-macro.html)

sross002

Sort Macro
 
Can someone please help me create a button (macro) that will sort a column in
desending order? Basically I just want to push a button and have column "b"
sort in desending order.

Thanks! I am new to Macros.

Gary''s Student

Sort Macro
 
Put the following in a standard module:

Sub demo()
Columns("B:B").Sort Key1:=Range("B2"), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Sub ButtonMaker()
Set r = ActiveCell
ActiveSheet.Buttons.Add(177.75, 5.25, 36, 28.5).Select
Selection.OnAction = "demo"
r.Select
End Sub

The run the ButtonMaker macro. Macros are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To use the macro from the normal Excel window:

1. ALT-F8
2. Select the macro
3. Touch Run



To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Gary''s Student - gsnu200848


"sross002" wrote:

Can someone please help me create a button (macro) that will sort a column in
desending order? Basically I just want to push a button and have column "b"
sort in desending order.

Thanks! I am new to Macros.


Jarek Kujawa[_2_]

Sort Macro
 
you wouldn't need a macro to achieve that
select any cell in range to be sorted in B column
then click Z-A icon in the Standard tollbar


On 23 Kwi, 14:40, sross002 wrote:
Can someone please help me create a button (macro) that will sort a column in
desending order? *Basically I just want to push a button and have column "b"
sort in desending order.

Thanks! *I am new to Macros.



sverre

Sort Macro
 


sross002 skrev:

Can someone please help me create a button (macro) that will sort a column in
desending order? Basically I just want to push a button and have column "b"
sort in desending order.

Thanks! I am new to Macros.


Try this one:

Sub SorterB()
Columns("B:B").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

After you have saved the VSB right clikk the mouse on tools and choose forms
(scheme, pattern). Click on the butten yoy want to appere. Then click the
place in the sheet you want to place it. The rest I thing you can manage.
By the way- the easy way to du it is to record a macro.
If you do any help to do that let me know



sross002

Sort Macro
 
Thank you both!

But I can't find the "schemes, patterns" button on the Forms toolbar that
SVERRE mentioned.

"Sverre" wrote:



sross002 skrev:

Can someone please help me create a button (macro) that will sort a column in
desending order? Basically I just want to push a button and have column "b"
sort in desending order.

Thanks! I am new to Macros.


Try this one:

Sub SorterB()
Columns("B:B").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

After you have saved the VSB right clikk the mouse on tools and choose forms
(scheme, pattern). Click on the butten yoy want to appere. Then click the
place in the sheet you want to place it. The rest I thing you can manage.
By the way- the easy way to du it is to record a macro.
If you do any help to do that let me know




All times are GMT +1. The time now is 09:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com