Finding Max value for a series of data

Melpp

New Member
Joined
May 3, 2011
Messages
29
I want to find the highest 5 values from a column using the macro functions (because it all needs to be automated). This column contains about 4000 data points and so it needs to be very efficient. I then want to display those five values in a table beside the existing one.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Maybe like this

Code:
Sub Lrg()
Dim i As Long
For i = 1 To 5
    Range("B" & i).Value = WorksheetFunction.Large(Columns("A"), i)
Next i
End Sub
 
Upvote 0
Something like this (assuming your data is in A1:A10, with output in column B)

Code:
Sub a()

Dim i As Long

For i = 1 To 5
    Cells(i, 2) = WorksheetFunction.Large(Range("A1:A10"), i)
Next i

End Sub
 
Upvote 0
I put in the following code but for some reason the line within the For loop has a error. Any ideas?

Sheets("Anterior").Select

For i = 1 To 5
Cells(4 + i, 9) = WorksheetFunction.Large(Columns("B"), i)
Next i
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,550
Members
452,927
Latest member
rows and columns

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