Sort data with command button

  • Thread starter Thread starter MarkV
  • Start date Start date
M

MarkV

How can I create a command button on an excel worksheet
that will sort the worksheet by data in one column? Since
the data will be increasing (more rows will be added) how
can I specifiy the range to include all rows?

Thanks
MarkV
 
There is already a button, The AZ and down/up arrows. Select the column and
press this button.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Yes that will work manually.

I don't want operators to select the range, because I am
afraid they will miss a column and the data will be out of
sync. I want the operator to press a button, which will
sort all rows by (say) column 1 values. How is this done
in vba code?

Mark
 
ActiveSheet.UsedRange.Sort key1:=Range("A1"), header:=xlGuess

although it may need refinement, for instance for headers.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top