
Sub Test()
Range("A2").Select
k = [A2].Value
r = Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To r
If Cells(x + 1, 1) > k Then n = n + 1
k = Cells(x + 1, 1).Value
Next x
[D1] = n
End Sub |
Sub test2()
Dim cMax As Long, R As Long
cMax = 0
For R = 3 To Range("A2").End(xlDown).Row - 1
If Cells(R, 1) > Cells(R - 1, 1) And Cells(R, 1) > Cells(R + 1, 1) Then cMax = cMax + 1
Next R
MsgBox cMax
End Sub |
Sub test3()
Dim cMax As Long, R As Long
cMax = 0
For R = 3 To Range("A2").End(xlDown).Row - 1
If Cells(R, 1) > Cells(R - 1, 1) Then
While Cells(R, 1) = Cells(R + 1, 1)
R = R + 1
Wend
If Cells(R, 1) > Cells(R + 1, 1) Then cMax = cMax + 1
End If
Next R
MsgBox cMax
End Sub
|
Option Explicit
Function Picco(Forze As Range, MaxPicco As Long) As Long
Dim F_orze As Variant
Dim Npicco As Long
Npicco = 0
Dim piu As Boolean
piu = False
For Each F_orze In Forze
If F_orze > MaxPicco Then
If piu = False Then
Npicco = Npicco + 1
piu = True
End If
Else
If F_orze < MaxPicco Then piu = False
End If
Next
Picco = Npicco
End Function |
