Sorting Values automatically when populated from another sheet.

Jamesba1

New member
Joined
Jul 24, 2019
Messages
5
Reaction score
0
Points
0
Excel Version(s)
2016
Hi,
I hope someone can help, be gentle I learning.
I'm trying to automatically sort the data in Column 2 of Chart. As the values are populated from the Data sheet, I can't see how to have them sorted automatically from smallest to largest.
I hope this makes sense. Thanks in advance.
 

Attachments

  • EXAMPLE.xlsx
    15 KB · Views: 10
Paste this in the Sheet1 Module :

Code:
Option Explicit



Private Sub Worksheet_Activate()
Dim lastrow As Long


lastrow = Cells(Rows.Count, 2).End(xlUp).Row
Range("A2:B" & lastrow).Sort key1:=Range("B2:B" & lastrow), _
   order1:=xlAscending, Header:=xlYes


End Sub

When the user goes from Sheet DATA to Sheet CHART, the sort will occur automatically.
 
If you don't want to use VBA, you can use the SMALL function to sort the values, then match up the names.
 

Attachments

  • EXAMPLE_SMALL.xlsx
    19.4 KB · Views: 23
Back
Top