Automatic Sorting of Sheet Based on One Column Value

meanwhilecreative

New Member
Joined
Mar 11, 2014
Messages
5
As the title suggests, I'm trying to sort a sheet of data based on a single column, and then have further entries automatically sort. The data has columns A-L, I would like it sorted based on column K, discounting the headers which are in row 1. The values in column K are 1,2 or 3 and there are be many ties or duplicates.

If anyone can help I would be most appreciative.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
OK, the sort is simple enough.....care to give us more information ?
Or paste a small sample of the data, and what you actually want to achieve beyond the basic sort of column K
 
Upvote 0
OK, the sort is simple enough.....care to give us more information ?
Or paste a small sample of the data, and what you actually want to achieve beyond the basic sort of column K

Thanks for replying.

The HTML Maker link seems to be down so I'm hoping I can explain.

The sheet is designed to log enquiries fielded to my place of work. The enquiries have many pieces of information such as date of enquiry, contact details etc. which are all column headings from A through to L. These enquiries (i.e. the row) should be ordered based on the data in column K, this is their classification as active, inactive or on hold, as represented by numbers 1, 2 or 3. I will be adding new enquiries to this document and changing the classification of existing enquiries and would like them to sort automatically based on this.

Is there any more information I can give? Any help would be much appreciated, I am only just beyond the very basics of Excel.

I am using Excel for Mac 2011, Version 14.3.8
 
Upvote 0
Maybe this.
It will resort the data when the Save Button is clicked
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Range("A2:L" & Cells(Rows.Count, "K").End(xlUp).Row).Sort Key1:=Range("K2"), Order1:=xlAscending, Header:=xlYes
End Sub
 
Upvote 0
Maybe this.
It will resort the data when the Save Button is clicked
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Range("A2:L" & Cells(Rows.Count, "K").End(xlUp).Row).Sort Key1:=Range("K2"), Order1:=xlAscending, Header:=xlYes
End Sub

This hasn't made any difference sadly. Thanks for your help all the same.
 
Upvote 0
did you get an error ??
Where is the code pasted ?
What did or didn't the code do ??

This hasn't made any difference sadly

This won't help us help you solve the problem !
 
Upvote 0
did you get an error ??
Where is the code pasted ?
What did or didn't the code do ??



This won't help us help you solve the problem !

Apologies. I tried the code in two places - once via the Record function under the developer ribbon, and then via the editor tool having gone to 'view code' on the sheet in question. I tried both of these and deleted the other when doing so.

There was no error message, nothing happened whatsoever. Closed and reopened the program and such like.
 
Upvote 0
You did click SAVE when you had finished the data input didn't you ??
 
Upvote 0
Hi, Michael -
I saw your replies to this post, and would like to ask a follow-up question:

I have the same issue as the original poster - sorting data on one sheet. I already have the code below included in the Workbook, but was wondering how I could incorporate your code into mine. The data I need sorted is included on Sheet2 via Column H descending. I've tried a couple times, and keep getting errors. Any help you can provide would be great!!!

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("sheet1").Unprotect ("led52not")
Sheets("sheet1").Columns("A:AB").Clear
Sheets("sheet1").Protect ("led52not")
Sheet2.Columns("A:AB").AutoFilter
Sheet2.Columns("A:AB").AutoFilter
End Sub


Thanks again.

Frank
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,378
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top