I have downloaded an excel spreadsheet from google docs.
In one column, are the names of people alphabetized. The other columns are the names of their club and another column is the town they live in. How do I set up the spreadsheet (now saved to my computer) so that if I click on any of these columns, the entire data will rearrange/alphabetized to the column I have selected? I have only been able to find out how to alphabetize a column but then just that column, (not all the columns) rearranges. One row of information is data of one person that needs to stay intact. Thank you!
You may use VBA to automate the Data Sorting so that whenever you select a column header, the data will be sorted in Ascending order in the column of the selected header.
It's always a best practice to add an Index column so that you can return to the original state of data by sorting the Index column at any time.
The attached file contains a Selection Change Event to sort the data automatically once you select a column header.
I have added an Index column which can be sorted to get back the data in it's original state. If you don't need the Index column, you can delete that column.
The following code is placed on the Sheet1 Module.
To implement the code to your original workbook, follow these steps...
Open your File.
Right click on Sheet Tab and choose View Code.
Paste the code given below into the opened code window.
Close the VB editor.
Save your Workbook either as .xlsm, .xls or .xlsb i.e. a file format which supports Macros in it.
Let me know if this is something you can work with.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Range("A1").CurrentRegion.Rows(1)) Is Nothing Then
Range("A1").CurrentRegion.Sort key1:=Target.Offset(1, 0), order1:=xlAscending, Header:=xlYes