Adding Clickable Sorting to Worksheet Lists : Range « Excel « VBA / Excel / Access / Word

VBA / Excel / Access / Word
1. Access
2. Application
3. Data Type
4. Data Type Functions
5. Date Functions
6. Excel
7. File Path
8. Forms
9. Language Basics
10. Math Functions
11. Outlook
12. PowerPoint
13. String Functions
14. Windows API
15. Word
16. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VBA / Excel / Access / Word » Excel » Range 
Adding Clickable Sorting to Worksheet Lists
 
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean
    Dim mnDirection As Integer 
    Dim mnColumn As Integer 
    If Target.Column < And Target.Row = Then 
        If Target.Column <> mnColumn Then 
            mnColumn = Target.Column 
            mnDirection = xlAscending 
        Else 
            If mnDirection = xlAscending Then 
                mnDirection = xlDescending 
            Else 
                mnDirection = xlAscending 
            End If 
        End If 
        Dim rg As Range 
        Set rg = Me.Cells(11).CurrentRegion 
        rg.Sort Key1:=rg.Cells(1, mnColumn), _ 
                 Order1:=mnDirection, _ 
                 Header:=xlYes 
    
        Set rg = Nothing 

    End If 
End Sub 

 
Related examples in the same category
1. Deletes a range and then fills the resulting gap by shifting the other cells to the left:
2. Select a range and activate another
3. Highlights selected range
4. Modify multiple cells at once using a range reference (like A1:A2)
5. To enter the name Florence into cell C10, you assign the name to the Value property of the Range object
6. If the Range object is not in the active worksheet in the active workbook
7. Assign the value in C1 in the active sheet to D10 in the sheet named Sales, in the active workbook
8. Assign the value of a property to a variable so it can be used in later code
9. Copies the contents of range A1:B3 to the clipboard:
10. Find in a range
11. Read a range from InputBox
12. Count the blank elements in a range
13. Sum the elements in a range
14. Show Edit Ranges
15. Expression refers to a cell one row below cell A1 and two columns to the right of cell A1: this refers to the cell commonly known as C2
16. Displays a message box that shows the value in cell A1 on Sheet1:
17. read the Value property only for a single- cell Range object: statement generates an error
18. Change the Value property for a range of any size: statement enters the number 123 into each cell in a range
19. Value is the default property for a Range object.
20. The Text property returns a string that represents the text as displayed in a cell: the formatted value. The Text property is read-only.
21. Count property returns the number of cells in a range (all cells, not just the nonblank cells). It's a read-only property.
22. The Column property returns the column number of a single-cell range;
23. Row property returns the row number of a single-cell range.
24. If the Range object consists of more than one cell, the Column property returns the column number of the first column in the range
25. If the Range object consists of more than one cell, the Row property returns the row number of the first row in the range.
26. Address, a read-only property, displays the cell address for a Range object in absolute notation (a dollar sign before the column letter and before the row number).
27. HasFormula property
28. Use object variables to represent the ranges
29. Building the Table
30. Returns the type of a range in an area
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.