Suggestions for VBA to Auto Sort and Group Rows of data

REUBEN

Board Regular
Joined
Mar 7, 2014
Messages
113
Hi All,

I have a sheet that is used to track a user's tasks/cases done during a day. Sort of a time tracking tool. The users are working on cases so each row has data on that specific case. The feature I am trying to incorporate in it is to automatically sort data when a particular amount of data has been added to the sheet. I have tried the example given by Allan Wyatt on this link - https://excel.tips.net/T009005_Automatically_Sorting_as_You_Enter_Information.html

here's the macro:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)    On Error Resume Next
    If Not Intersect(Target, Range("B:E")) Is Nothing Then
        Range("B2:E2").Sort Key1:=Range("B3:E3"), _
          Order1:=xlAscending, Header:=xlYes, _
          OrderCustom:=1, MatchCase:=False, _
          Orientation:=xlTopToBottom
    End If
End Sub

But the above code sorts data as soon as I have entered anything in the first column. It would be good if it waited till a few more subsequent fields are populated before sorting.

Now what I am working to get is a more advanced version of this macro. That would include the following:

1) Auto sort data only after a certain fields of each row is completed. To put that in perspective, column 1 has the name of the task/case, column 2 the type of activity, column 3 the date the task is being done...... until column 8 that calculates the total time used on that task/case. But the macro can carry out the auto sort soon after there's data in the column 4.

2) Scroll the user's view of the sheet over to where the row would have moved in the sheet.

3) Select the next cell in that row.

Other suggestions needed are:

1) How can we ensure that the user always enters data in the next empty row only. And not randomly anywhere in the sheet. Should a userform be used everytime a new Task/Case details have to be entered in the sheet?

2) Is there a way to group the times of the same Case/Task so one can see how long a task or case took in the end to be completed? (Note: tasks/ cases can sometimes go on for a few weeks or even months so totalling the time spent on each and every specific task).

Thank you.
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,223,275
Messages
6,171,126
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top