• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

find secondhighest value from a selection

Dalia

Member
why not happening?
please find below the macro code

Sub macro()


Dim highestval As Double
Dim sechighestval As Double
Dim rng As Range
Dim rang As Range


Set rng = Selection
highestval = 0
sechighestval = 0
For Each rang In rng
Next rang
Set rang = Nothing
If rang.Value > highestval Then highestval = rang.Value
For Each rang In rng
Next rang
If rang.Value > sechighestval And cell.Value < highestval Then sechighestval = cell.Value
MsgBox "second highest value is " & sechighestval
End Sub
 
Is this...

Code:
Sub macro()
Dim rng As Range

Set rng = Selection

MsgBox Application.Large(rng, 2)

End Sub
 
Back
Top