VBA Auto sort looking at if changes in other sheets for changes?

Emerlin

Board Regular
Joined
Jan 8, 2007
Messages
105
Hi,

I am using this VBA script to get some sorting done. But my cells reference formulas on other sheets that do not trigger it as the cell changing - hope that makes sense. Can I nest and Else if to look at the other sheets to trigger the changes?

Working...

Private Sub Worksheet_Change(ByVal Target As Range)
'Sort Name
On Error Resume Next
If Not Intersect(Target, Range("C3:H17")) Is Nothing Then
Range("C3:H17").Sort Key1:=Range("H3:H17"), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub

Something like....

Private Sub Worksheet_Change(ByVal Target As Range)
'Sort Name
On Error Resume Next
If Not Intersect(Target, Range("C3:H17")) Is Nothing Then
ElseIf Not Intersected (Sheet("Sheet2").Range("A1:A33)) Is Nothing Then
Range("C3:H17").Sort Key1:=Range("H3:H17"), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub

I am trying to get the sorting to trigger if changes occur in either sheet or possibly sheets in the future.

Thanks in advance for any/all help.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

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