Hello
I want to clear some doubts about sorting
the following code sorted perfectly
Just
1. When rows of records are entered after sorting. Then want to sort it with new records it does not sort. I dont understand Why ?
2. So when do i need to sort. Any particular criteria required for sorting
3. Also my P2 cell has header Value though in the below code Header:=xlNo and data starts from row 3 so do i need to change to
Sort Key1:=Range("P3")
NimishK
I want to clear some doubts about sorting
the following code sorted perfectly
Just
1. When rows of records are entered after sorting. Then want to sort it with new records it does not sort. I dont understand Why ?
2. So when do i need to sort. Any particular criteria required for sorting
3. Also my P2 cell has header Value though in the below code Header:=xlNo and data starts from row 3 so do i need to change to
Sort Key1:=Range("P3")
Code:
Private Sub cmdSorting_Click()
Dim ws As Worksheet
Set ws = Worksheets("MIS")
ws.Activate
Dim lastRow As Long
lastRow = ws.Cells(ws.Rows.Count, 2).End(xlUp).row
ws.Range("A3:BC" & lastRow).Sort Key1:=Range("P2"), Order1:=xlAscending, Header:=xlNo
End Sub
Last edited: