Sort Ascending or Descending using Option Button

  • Thread starter Thread starter Gazza
  • Start date Start date
G

Gazza

I have a user-form with 3 option buuttons, depending on which option is
clicked the event runs and the data is sorted by the relevant column. How do
I add in an extra couple of options that will toggle between sorting the
data select option either ascending or descending.

thanks

Gaz
 
I assume you are up to date on adding option buttons to the form and are
looking for code modifications to use the choice. with two option buttons
OptionButton_Ascending
Optionbutton_Descending


Dim ord as Long

ord = 0 ' no choice made
if optionbutton_Descending then
ord = xlDescending '2
elseif optionbutton_Ascending then
ord = xlAscending '1
end if

if ord = 0
' use current setting
selection.Sort Key1:=whatever
else
' use selected order
selection.Sort Key1:=whatever, order1:=ord
end if
 
You may want to consider using a single checkbox with a "Sort Ascending" label.

Then you could just look at that one checkbox's value.
 
My original thought as well, but the sort dialog uses two option buttons -
so for interface consistency.
 
Not sure how to action this...

I used the click event on each of the original options to run a macro to
sort the data table. I have now grouped the original 3 options into a single
frame - how would I proceed to get the data sorted firstly based on the sort
option click and then by the direction of sort from the other 2 options
located on a second frame and would all this code need to be written on a
general module?

Thanks

Gaz
 

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