Aug 31 2019 02:50 PM
Hello,
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!
Aug 31 2019 05:10 PM
Hi
Before applying any sort to your list, make sure of:
Accordingly Excel will resize the selection and sorts All the records based upon the column you specified.
When you select a Single cell in the column you want (Name or Club or Town) you can sort by:
I attached a Sample File
Good Luck
Nabil Mourad
Aug 31 2019 09:34 PM
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...
Let me know if this is something you can work with.
Code:
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
ActiveSheet.Sort.SortFields.Clear
Range("A1").CurrentRegion.Sort key1:=Target.Offset(1, 0), order1:=xlAscending, Header:=xlYes
End If
End Sub