Hi Folks
Just a quick one, hope its an easy one for someone.
How do i make a sheet sort a small table of data from A-Z automatically every time i open that sheet?
Any ideas.
Cheers in Advance
Chris
Hi Folks
Just a quick one, hope its an easy one for someone.
How do i make a sheet sort a small table of data from A-Z automatically every time i open that sheet?
Any ideas.
Cheers in Advance
Chris
Paste the following macro into the ThisWorkbook tab in the VBA editor (Alt F11) and adjust as necessary to specify the sheet, the range of data and the column to sort by.
![]()
Private Sub Workbook_Open() Sheets("MySheetName").Cells(1, 1).CurrentRegion.Sort Header:=xlYes, key1:=Sheets("MySheetName").Cells(1, 1), order1:=xlAscending End Sub
Last edited by mrice; 01-30-2010 at 09:25 AM.
Martin
Hi,
I'm assuming when you refer to a sheet in your original post, you really do mean a sheet and not the workbook.
In the VBE use the Sheet_Activate event procedure and enter the following line of code
change the order:= if necessary to xlDescending, and add further sort keys if required.![]()
Private Sub Worksheet_Activate() Range("A1").CurrentRegion.Sort key1:=Range("A2"), order1:=xlAscending, header:=xlYes End Sub
If you mean when you open the workbook then use the same line of code in the Workbook_Open event.
HTH
Last edited by Richard Buttrey; 01-30-2010 at 09:24 AM.
Richard Buttrey
RIP - d. 06/10/2022
If any of the responses have helped then please consider rating them by clicking the small star iconbelow the post.
Hi Richard
Thanks very much, this works a treat, Muchly Appreciated.
Thanks Again
Chris
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks