Excel VBA自动生成新增行的同时自动生成ID增量
发布时间
阅读量:
阅读量
Excel VBA 自动添加新行并递增ID
通过Excel 2010的VBA功能实现数据处理,其核心依据为IP网段及该网段内IP地址的数量,从而生成对应的每一个IP地址,并完成相应的ID编号分配。
Sub AutoInsert()
Line = 1531
Count = Cells(Line, 5).Value
''Count = 5
For i = 2 To Count
''Copy
Range(Cells(Line + i - 2, 1), Cells(Line + i - 2, 6)).Select
Selection.Copy
''Insert
Range(Cells(Line + i - 1, 1), Cells(Line + i - 1, 6)).Rows.Insert
'' Change Id and Ip Cell Value
''Id: ESP004001
IdVal = Cells(Line + i - 1, 2).Value
If i = 2 And InStr(IdVal, "ESP") = 0
全部评论 (0)
还没有任何评论哟~
