如何创build从1到最后一组的系列

我有一个像下面的Excel中的数据

month 1 4 12 12 12 12 6 8 7 12 12 12 12 12 12 7 10 12 12 12 

如何只给12系列如下

 month Series 1 4 12 1 12 2 12 3 12 4 6 8 7 12 1 12 2 12 3 12 4 12 5 12 6 7 10 12 1 12 2 12 3 

提前致谢

在放置数据的工作表代码模块中尝试以下代码。 我假设列A是 ,列B是系列

 Sub Checking_Value() Dim i As Long, LastRow As Long, n As Long LastRow = Cells(Rows.Count, "A").End(xlUp).Row n = 0 For i = 1 To LastRow If Cells(i, 1).Value = 12 Then n = n + 1 Cells(i, 2) = n Else n = 0 End If Next i End Sub