excel如何将一个单元格中自动编号?比如:NO:20130501.打印下一次单时变成NO:20130502

2025-01-27 12:35:29
推荐回答(2个)
回答1:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
N = Right(Range("I2"), 8) + 1
Range("I2") = "NO:" & Format(N, "00000000")
End Sub
8位数的数字 你取7位 有问题吧?

回答2:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
N = VALUE(Right(Range("I2"), 8)) + 1
Range("I2") = "NO:" & Format(N, "00000000")
End Sub
第一、你应该取8位,第二、应该把文本型改成数据型