1

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

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .