Macro for a button

Wayne H

New Member
Joined
Jun 8, 2011
Messages
3
Hi,
I am wanting a button in a sheet (excel 2003) with a macro or command to select a group of cells and then put the data in ascending order.

I have been able to insert the button but do not know where to go from here.

I have no experiance with macro or visual basic.

Any assistance apreciated.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Why would you want to create a macro that is attached to a button for asscending sort? You have this capability on the data tab sort button or hilight the selection right click and you will see sort.
 
Last edited:
Upvote 0
This is a sheet used by other people and not all can use computers very well, this is to minimise their input.
 
Upvote 0
Make some data in cells.
Go Extras - Macros - Record
Do what should be done by the butt******* (mark cells, sort)
Stop recording.
Look in the code, you see this:

Code:
Sub Makro2()
    Range("D7:D11").Select
    Selection.Sort Key1:=Range("D7"), Order1:=xlDescending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
End Sub

now modify the Range you want to have sorted, can include empty cells.


Add a Button via controlelements - toolbox

Connect the Makro2 to the Button.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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