Jul 02 2020 10:49 PM
Jul 02 2020 10:49 PM
Hoping to get some help on a macro in order to sort an entire worksheet by date.
I have multiple rows and the first column is the date (using a date and time picker macro). People will be going in and filling out the spreadsheet, but with each row of information, the date of that item may change to a later date. I want to have a macros where by when the date of a row is changed in column A, it moves the entire row up or down to order it in the order of the date. Does this make sense?
The one macro I found is below, but I'm not sure how to change it in order to read the entire sheet and move the rows. I also already have a date and time picker macro in the sheet, so wondering would I just paste this below it? Any help?
Jul 03 2020 09:58 AM
@stephanieporter Hey I have created a simpler Macro you can try this Macro
' Macro2 Macro
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:=Range _
("A1:A1048576"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
I am also attaching the file you can check whether it is running
Jul 07 2020 10:16 PM
Ok so not sure it's working. The code thats currently in my work book (for column a to have date and time pickers in it) is:
Private Sub DTPicker1_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
.Height = 20
.Width = 20
If Not Intersect(Target, Range("A115:A120,A122:A131")) Is Nothing Then
.Visible = True
.Top = Target.Top
.Left = Target.Offset(0, 1).Left
.LinkedCell = Target.Address
.Visible = False
I now need something to sort all the rows by date should we decide to change the date on something, I want it to automatically move all the content and align them in date order (if possible). There are 17 columns of information that all needs to stick together. Am I making sense? I can't post a copy of the work book as it's confidential information.
Jul 07 2020 11:06 PMSolution
@stephanieporter Please check the following video and following excel whether I understood correctly what you wanted to say.
And still if you have any query in VBA then you can also message me privately or on my mail id
And if you liked my answer please do mark my answer as best answer officially