HERE IS A ONE LINE CODE FOR DEVELOPER’S REFERENCE WHICH CAN BE USED TO SORT DATA
'Sort data in ascending order on Column F (Created At)
Sheet1.Range("A1:G" & Sheet1.Cells.SpecialCells(xlCellTypeLastCell).Row).Sort Key1:=Sheet1.Range("F1"), Order1:=xlAscending, Header:=xlYes, DataOption1:=xlSortNormal
After Sort:
IF YOU ARE LOOKING FOR A VBA CODE THAT CAN SORT THE DATA ON MULTIPLE COLUMNS AT THE SAME TIME THEN BELOW CODE MAY HELP YOU:
Public Sub SortByMultipleColumn()
   '
   'Clear old sort field
   Sheet1.Sort.SortFields.Clear
   'Add sort field on column D (Department ID)
   Sheet1.Sort.SortFields.Add Key:=Sheet1.Range("D2:D20"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
   'Add sort field on column F (Created At)
   Sheet1.Sort.SortFields.Add Key:=Sheet1.Range("F2:F20"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
   With Sheet1.Sort
       .SetRange Range("A1:G20")
       .Header = xlYes
       .MatchCase = False
       .Orientation = xlTopToBottom
       .SortMethod = xlPinYin
       .Apply
   End With
   '
End Sub
Before Sort:
After Sort:
VBA Code To Delete All Shapes On A Excel sheet Here is a VBA code which deletes all the shapes from an Excel sheet. Code is simple but you have to be bit careful while…
What is the Usage of sheet color in Excel? When we prepare a report or a dashboard it is easy to identify or analyze reports with a change of color sheet tabs. Analysts generally give…
Outlook Email Management Tool is an Excel based tool which works with Outlook 2010 or above version and helps you to read, copy or move multiple emails from an Outlook folder and sub-folders on click of a button. The tool also supports extracting attachments from emails as well.
VBA Code to list Files in Folder To work on multiple files through VBA programming, you need to have VBA code that can list files in a folder. In this article we will learn three…
Did you come across any requirement where you want the user to interact with a sheet only through VBA Form? Here is a simple code which can help you.
VBA Code To Change Cell Color Excel supports more than 16 million colors in a cell; hence you should know how to set the exact color in a cell. To do this, you can use…