Hi Ron,
cells A2..M150 contain the data
I would want the primary sort to be on column E
with a secondary sort on column A
I am guessing that you have a Total in Row 151 and
don't want to sort that, so I took steps to include rows
above the last row with content in Column A. If that
is not the case then look at the macro above the one
I will be pointing you to.
I created a pair of Worksheet Event macros for you that
might work out better for you than a command button, if there
is only one sort sequence you are interested in.
Event macros are triggered by an Event and are installed
differently from regular macros. The Event macros
that I created are for when the worksheet is activated,
and a double-click macro that initiates the worksheet activate
so you don't have to leave the worksheet.
See Example at
http://www.mvps.org/dmcritchie/excel/sorting.htm#activate
more information on Event macros at
http://www.mvps.org/dmcritchie/excel/event.htm
When you sort things manually you are generally better off
to select all cells on the worksheet (Ctrl+A) before going to
Data, Sort... -- That way all data will go with your sorted keys.
Unless you meant to sort the columns independently
of anything else in which case select a column, invoke the
sort, then select another column and sort it -- without any
associated data in the other columns.
When you copy and paste into Excel from an HTML source you
will probably have CHAR(160) which in HTML is
the nonbreaking space character. They may appear not
to interfere with characters, but they definitely will interfere
with numbers in Excel worksheets. You will probably want to
use the TRIMALL macro found at
http://www.mvps.org/dmcritchie/excel/join.htm#trimall
Did you know that you can sort a table right in your HTML
web page (or someone else's) -- one column. Unfortunately
Internet Explorer is limited to the size of a bookmark that you
can have in your Favorites (or Links on your IE Toolbar).
But it works fine from Mozilla or if the shortcut is actually on
the webpage as a link. See
http://www.mvps.org/dmcritchie/ie/bookmarklets.htm#sandbox
If you still want a Command Button you would right click on it
and assign a macro such as (this one sorts entire worksheet).
http://www.mvps.org/dmcritchie/excel/sorting.htm#record
We are a friendly bunch here, in the Excel newsgroups, and it's a lot more
friendly and professional to use your first and last name when posting, so
we know who we are talking to. If ExcelForum does not make that easy
when it redirects you to newsgroups then please include your first and
last name in your signature line.