Setting up a Command Button to sort

  • Thread starter Thread starter rg8407
  • Start date Start date
R

rg8407

i am very new with using command buttons. I have set up several to wor
correctly, but have unable to set up one to sort data. What I want t
do is copy and paste and HTML report into my spreadsheet and then clic
on a Sort Command Button to sort it the way I need to view. The sor
is always the same. The information for the spreadsheet is a
follows:

cells A2..M150 contain the data
I would want the primary sort to be on column E with a secondary sor
on column A if this is possible.

Can someone please tell me how to program this command button to sor
this way.

Thanks,
Ro
 
Hi Ron
one way:
- record a ,acro whild doing the sort manually
- assign this macro to a button
 
Thanks Frank but I have two questions:

First, I am relatively new to all this more detailed Excel work. I
this very difficult to do? Is there a book you can recommend to hel
me with this type of stuff?

Second, can I do this so it recognized the number of rows that ar
there? I changed the post from the time you saw it. There will be
varying number of rows pasted into the spreadsheet, however the column
will stay the same. I need to make this as simple as possible to us
because the production workers will rely on it daily. They will nee
to re-run it often, so the simpler for them, the better. One button t
do this would be a big help.

Thanks for your help,
Ro
 
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.
 
Back
Top