Sorting Data with code

shyamvinjamuri

Board Regular
Joined
Aug 2, 2006
Messages
175
I have Date in Column A, Column B,C and D have date. Every day the sheet is updated with today's date in Column A and Data in Columns B,Cand D.
Upon the entry of today's data, I would like to auto sort so that today's date and data shows at the top of the cloumn.

I am new to VBA. Any help is highly appriciated.

Thanks
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi
Paste the code onto sheet module
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
      If .Count > 1 Then Exit Sub
      If .Column <> 1 Then Exit Sub
      If .Value <> Date Then Exit Sub
End With
Application.EnableEvents = False
Range("a1").CurrentRegion.Resize(,4).Sort _
       key1:=Range("a1"),order1:=xlDescending, header:=xlGuess
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,539
Members
449,088
Latest member
RandomExceller01

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