VBA wont run automatically when cell change

GedSalter

Board Regular
Joined
Apr 24, 2019
Messages
80
hi.

I have the following VBA code. I need it to run automatically when a cell has changed.


VBA Code:
Sub SORT()
'
' SORT Macro
'
    Range("AO1:AP10").Select
    ActiveWorkbook.Worksheets("Tipping").SORT.SortFields.Clear
    ActiveWorkbook.Worksheets("Tipping").SORT.SortFields.Add2 Key:=Range( _
        "AP2:AP10"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
        xlSortNormal
    ActiveWorkbook.Worksheets("Tipping").SORT.SortFields.Add2 Key:=Range( _
        "AO2:AO10"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("Tipping").SORT
        .SetRange Range("AO1:AP10")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    Range("AO15").Select
End Sub

I have put the code into the Sheet 1"Tipping" code section. But it doesn't do anything whatsoever. I am sure its a fundamental mistake on my behalf.

Thank you in advance.

Ged
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Worksheet change must always be named: "Worksheet_Change"
VBA Code:
Sub Worksheet_Change(ByVal Target As Range)
 
Upvote 0
Solution

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

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