小项 就是 数字 递增,根据前面的
A列先输入 A
Sub 大项()
Dim i
For i = Range("A65536").End(xlUp).Row To 1 Step -1
x = Asc(Cells(i, 1))
If (x >= 65 And x <= 90) Then
n = Range("A65536").End(xlUp).Row
Cells(n + 1, "A") = Chr(1 + x)
Exit Sub
End If
Next
End Sub
Sub 小项()
Dim n
n = Range("A65536").End(xlUp).Row
x = Asc(Cells(n, 1))
If (x >= 65 And x <= 90) Then
Cells(n + 1, "A") = 1
Else
Cells(n + 1, 1) = Cells(n, 1) + 1
End If
End Sub
代码如下。
打开你的Excel文件,按“Alt+F11”打开VBA编辑窗口,然后在左侧对应的Sheet上双击,右侧空白处粘贴下面的代码。关闭VBA窗口。然后按“Alt+F8”打开宏窗口,选择刚插入的宏,点击“执行”。
Sub xh()Dim rg As Range
Dim i, r, n As Long
r = Cells(Rows.Count, 2).End(xlUp).Row
For Each rg In Range("B2:B" & r)
If rg.Row = 2 Then
n = 0
Else
If rg.Value = rg.Offset(-1, 0).Value Then n = n + 1 Else n = 0
End If
rg.Offset(0, -1).Value = n
Next
For i = r To 2 Step -1
If Cells(i, 1) = 0 Then
If Cells(i + 1, 1) <> 1 Then Rows(i).Delete
Else
If Cells(i + 1, 1).Value = 0 Then Rows(i + 1).Insert: Cells(i + 1, 1).Value = "End"
End If
Next
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)