VBA auto sort triggered from different sheet

SuperSoupGuy

New Member
Joined
Nov 30, 2017
Messages
2
Hi all,

I'm not able to solve this problem using existing threads on this forum so here's the thing:

I have a data on "sheet4" which I would like to sort automatically (descending by column C, data starts at row 4) triggered by changing selection from drop down list placed in "B5" on "sheet2".

Right now I have this code (in worksheet code) which sorts the data but only when data in column C on sheet4 are changed:


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("C:C")) Is Nothing Then
Range("C3").Sort Key1:=Range("C4"), _
Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub

Do you please have any idea on how to change it and where to insert it? (which worksheet, new module, etc...) My VBA skills are limitally close to zero.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi, welcome to MrExcel
How about this
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Intersect(Target, Range("B5")) Is Nothing Then Exit Sub
    Sheets("[COLOR=#ff0000]Sheet4[/COLOR]").Range("C3").Sort Key1:=Sheets("[COLOR=#ff0000]Sheet4[/COLOR]").Range("C4"), _
        Order1:=xlDescending, Header:=xlYes, _
        OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom
        
End Sub
Delete your existing code & place this in the sheet2 module. This assumes that the sheet to be sorted is called Sheet4 (ie that is the name on the tab)
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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