Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have limited Excel knowledge.
I have 2 columns, column A is names, column B is manually updated with numbers. Can I add a button or automatically data sort column B then A
Any help would be appreciated, many thanks

You can assign this code to a button or shape to sort A1:B10 with a single click:
Sub MySort()
Range("A1:B10").Sort _
Key1:=Range("B1"), Order1:=xlAscending, _
Key2:=Range("A1"), Order2:=xlAscending
End SubOr Right-Click your sheet tab and use it as a WorkSheet_Change macro to do it automatically:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B1:B10")) Is Nothing Then
Range("A1:B10").Sort _
Key1:=Range("B1"), Order1:=xlAscending, _
Key2:=Range("A1"), Order2:=xlAscendingEnd If
End Sub

Many thanks DerbyDad03 used the worksheet change macro, it works fine, but when saved and file reopened it does'nt work but code still assigned to tab.
Can you suggest anything ?

Many thanks Derbydad03, changed the Macro security setting and all works fine
your help is much appreciated

![]() |
Using VBA for Cond Format...
|
MSN Live Photo
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |