编辑
2024-05-14
日常系统操作
00
请注意,本文编写于 116 天前,最后修改于 116 天前,其中某些信息可能已经过时。

excel表格

excel表格中检测B列如果存在则A列自动累加到不重复后继续下一单元格填充数据,如图所示

image.png

Sub GenerateUniqueValues() Dim ws As Worksheet Dim i As Long Dim currentValue As Long Dim isUnique As Boolean Set ws = ThisWorkbook.Sheets("Sheet1") ' 请确保 "Sheet1" 是你的工作表的名称 currentValue = 1 ' 从1开始计数 For i = 1 To 9876 isUnique = False Do While Not isUnique If IsError(Application.Match(currentValue, ws.Range("B:B"), 0)) Then isUnique = True Else currentValue = currentValue + 1 End If Loop ws.Cells(i, 3).Value = currentValue ' 3表示C列 currentValue = currentValue + 1 Next i End Sub

本文作者:SnailBoy

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!