Sorting Data with code

shyamvinjamuri

Board Regular
Joined
Aug 2, 2006
Messages
174
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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
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
 

Forum statistics

Threads
1,137,204
Messages
5,680,160
Members
419,887
Latest member
Vasokir

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
Top