ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How can I set up Excel to auto-sort each column independently? (https://www.excelbanter.com/excel-worksheet-functions/180261-how-can-i-set-up-excel-auto-sort-each-column-independently.html)

davisjw

How can I set up Excel to auto-sort each column independently?
 
I want to track my DVD collection but I only need a list of titles, sorted
alphabetically. Catalogue software wants to store numerous other attributes
for each title and usually offers a complex interface. But all I want is
titles, so I thought that perhaps I can create a simple list in Excel where I
use columns a-z to store titles alphabetically.

My question is: is it possible to set up my worksheet so that Excel
auto-sorts the content of each column independently of, and without reference
to, other columns?

NoodNutt

How can I set up Excel to auto-sort each column independently?
 
G'day

Try this:

Open the Visual Basic Window

Put this in the "Workbook" section of your spreadsheet

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Application.OnTime Now + TimeValue("00:30:00"), "AutoSort"
End Sub


Every 30 mins it will "AutoSort" the range you have selected.


Create a Module in the Visual Basic Window.

Call it "AutoSort"

Sub AutoSort()
Range("YourStartRange:YourEndRange").Select
ActiveWorkbook.Worksheets("YourSheetName").Sort.So rtFields.Clear
ActiveWorkbook.Worksheets("YourSheetName").Sort.So rtFields.Add
Key:=Range("YourStartRange:YourEndRange"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("YourSheetName").Sort
.SetRange Range("YourStartRange:YourEndRange")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

The (Add Key:=Range) is the column which you want to sort.

You can also place a macro button on your spreadsheet so that you can
manually trigger the sort.

HTH
Mark




NoodNutt

How can I set up Excel to auto-sort each column independently?
 
Just to clarify my previous post.

List all your DVD titles in one column, this will enable you to keep track
of how many you have, and if you choose later, somewhere down the track, you
can enter additional info about the movies, eg Stars, Director, Your Rating
on it, Who you lent it to, etc etc............................

HTH
Mark.




All times are GMT +1. The time now is 06:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com