Auto Sort By Purchase Order Number

Russ At Index

Well-known Member
Joined
Sep 23, 2002
Messages
706
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Hi All,

I would like to perform the folllowing within a worksheet.

In column "A" i am entering a PO number then i have assorted
information relating to that PO in columns B.C.etc.

My question is .... would it possible to , when a PO has been entered
into col A can Excel automatically sort that row to run in numerical
order ?

Thanks In Advance

Russ
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hello Russ,
Sure.
Try one of these in the sheet module.
(Right click the sheet tab & choose View code.)
Paste one or the other routine (not both) into the white sheet module.
If you want to sort the entire column (from row 1 down):
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 1 Then _
  Columns("A:D").Sort Key1:=Range("A1"), Order1:=xlAscending
End Sub

If you don't want to include row 1 (headers for instance) then you can use this one instead.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LstRw As Long
LstRw = Cells(Rows.Count, "A").End(xlUp).Row
If Target.Count > 1 Then Exit Sub
If Target.Column = 1 Then _
  Range("A2:D" & LstRw).Sort Key1:=Range("A2"), Order1:=xlAscending
End Sub
Note: In either case, amend the column D in the code to the furthest column out that you want included in the sorting.

Press Alt+Q to get back to the sheet & try it out.
 
Upvote 0
Morning Half Ace,

Works like a Saturday morning dream ..............

Unfortunatley i am at work .........

Thanks Again

Russ
 
Upvote 0

Forum statistics

Threads
1,214,873
Messages
6,122,029
Members
449,061
Latest member
TheRealJoaquin

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