ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Worksheet Sort Data (https://www.excelbanter.com/excel-programming/383039-open-worksheet-sort-data.html)

TonyD

Open Worksheet Sort Data
 
When I open a worksheet (Refer To CT), I want to automatically sort a named
range by column A in descending order so that blank row are at the bottom.
The named range is "CTReferRecords". Can anyone help me with the code?

Tom Ogilvy

Open Worksheet Sort Data
 
Use the sheet activate event

right click on the sheet and select view code:

Put in code like this

Private Sub Worksheet_Activate()
Dim rng As Range
Set rng = Range("CTReferRecords")
rng.Sort Key1:=rng(1), Order1:=xlAscending, _
Header:=xlYes
End Sub

I open workbooks and activate worksheets, so I may not understand your
situation.

--
Regards,
Tom Ogilvy



"TonyD" wrote:

When I open a worksheet (Refer To CT), I want to automatically sort a named
range by column A in descending order so that blank row are at the bottom.
The named range is "CTReferRecords". Can anyone help me with the code?



All times are GMT +1. The time now is 07:25 AM.

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