Sub Number() 'Made by Towa Tachibana, on July 10, 2003 ' Make numbering following firm indices, tree names, etc ' For example, the data is ' Hitachi ' Hitachi ' Hitachi ' Matsushita ' Sanyo ' Sanyo ' This macro makes ' 1 ' 1 ' 1 ' 2 ' 3 ' 3 Dim Ly As Integer Dim i As Integer Dim j As Integer Ly = Selection.Rows.Count j = 1 For i = 4 To Ly + 2 'The data starts from line 4. But we counted one line of title "p". Thus need to add 2 ' First eleven line are the indices and explanations ' This macro assumes that the data starts from the 12th line of column 3. ' If the entry of column 1 of line 12 = that of line 13, put j in line i of column 4. LOCAL_TREE = Cells(i, 3).Text LOCAL_TREE1 = Cells(i + 1, 3).Text If LOCAL_TREE1 <> "" And LOCAL_TREE1 = LOCAL_TREE Then Cells(i, 4) = j Else: Cells(i, 4) = j Cells(i + 1, 4) = j + 1 j = j + 1 End If Next i Cells(Ly + 2 + 1, 4) = "" 'Delete the entry of the last line End Sub