Generate chart from highest three values in a table

sogs0707

New Member
Joined
Sep 25, 2014
Messages
13
Hello all,

I have a table which lists categories with percentages which will change every month. I want to have a chart which will automatically pull the highest three values from the table. Is that possible?

Thanks,

Sogs0707
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
What you should do is to set up a small table which uses formulas to pick the highest values from your data. Using a function like LARGE

So its the smaller table with the highest 3 values that you then plot,. Once the big table changes, the smaller table('cos it uses formulas to pick) updates as well
 
Upvote 0
What you should do is to set up a small table which uses formulas to pick the highest values from your data. Using a function like LARGE

So its the smaller table with the highest 3 values that you then plot,. Once the big table changes, the smaller table('cos it uses formulas to pick) updates as well

A great starting point. I shall give it a try, thank you!
 
Upvote 0
.
.

Try something like this:

Code:
Sub AddColumnChart()
    
    'Adds a clustered column chart
    'to the active sheet
    'using the 3 largest series values
    'from the specified range
    
    Dim s_vals As Range
    Dim add As String
    Dim cht As Chart
    
    Set s_vals = ActiveSheet.Range("A1:A16")    'change this line
                                                'to the range
                                                'containing your
                                                'series values
    
    add = "=" & _
        LargeAdd(s_vals, 1) & "," & _
        LargeAdd(s_vals, 2) & "," & _
        LargeAdd(s_vals, 3)
    
    Set cht = ActiveSheet.Shapes.AddChart.Chart
    
    With cht
        .ChartType = xlColumnClustered
        .SeriesCollection.NewSeries
        .SeriesCollection(1).Values = add
    End With

End Sub

'--------------------------------------------------------------------------

Private Function LargeAdd(rng As Range, k As Long) As String

    'Returns the address
    'of the k-th largest value
    'in a range
    
    LargeAdd = rng.Parent.Name & "!" & _
        rng.Find(WorksheetFunction.Large(rng, k)).Address

End Function
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

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