Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

UPDATE
An example can be seen on this page http://www.the87boy.dk/membershiplist.php

share|improve this question
add comment

1 Answer

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()
Columns("B:E").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
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
    .Apply
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
add comment

Your Answer

 
discard

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.