Sub test() Dim r As Long, arr Dim f As Boolean Dim n As Integer r = Range("A65536").End(xlUp).Row - 2 Cells(3, 2).Resize(r).ClearContents With Cells(3, 1).Resize(r, 2) arr = .Value n = 2 f = arr(2, 1) > arr(1, 1) For r = 3 To r t = arr(r, 1) > arr(r - 1, 1) If t = f Then n = n + 1 Else If n > 2 Then arr(r - 1, 2) = IIf(f, "↑", "↓") & n n = 2 f = t End If Next If n > 2 Then arr(r - 1, 2) = IIf(f, "↑", "↓") & n .Value = arr End With End Sub
手慢了…… Sub My() Dim i, j, Asc_y, Desc_y Dim arr, brr i = [A65536].End(3).Row arr = Range("A3", "A" & i + 1) ReDim brr(1 To i) a: j = j + 1 If j = UBound(arr) Then GoTo b If arr(j, 1) - arr(j + 1, 1) = 1 And Asc_y = 0 Then Desc_y = Desc_y + 1 ElseIf Desc_y <> 0 Then If Desc_y + 1 > 2 Then brr(j) = "↓" & Desc_y + 1 Desc_y = 0 End If If arr(j, 1) - arr(j + 1, 1) = -1 And y = 0 Then Asc_y = Asc_y + 1 ElseIf Asc_y <> 0 Then If Asc_y + 1 > 2 Then brr(j) = "↑" & Asc_y + 1 Asc_y = 0 End If GoTo a b: Range("B3", "B" & i) = Application.Transpose(brr) End Sub