Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a membership list like this in Excel

| A | 02-02-1994 | B | C
| D | 04-10-1998 | E | F

I want to change it, so it can be ordered by age (the 2nd column) or by name (the 1st column)

As you can the see the age is set up with a date and with that and a defined variable (hidden in another column). I need to calculate the age
That is not the problem

The problem is how I can let the user decide if he/she wants to sort by name or by age (like a Pivot)
I am using Excel 2003

Right now I am creating an HTML-page so you can see what I mean, if you can not see it from the question

An example can be seen on this page

share|improve this question
up vote 0 down vote accepted

Insert a column (that is not sorted later, so the buttons stay put) and in it insert a couple of Button Form Controls with macros assigned. Assuming A and D are in ColumnB of Sheet1 and no gaps, for example:

Sub Macro1()
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("B:B"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
    .SetRange Range("B:E")
    .Header = xlGuess
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
End With
End Sub

or record it yourself.

I named the button with that code Name Order and the other (with C:C in place of B:B) Age Order.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.