|
我需要根据 货物名字和货物数量,自动生成货物编号。因为货物品种很多,然后的话件数可能上百,我需要一个函数公式自动求得编号如图
|
该用VBA的时候还是要用VBA的
- Sub dd()
- Dim i&, j&, n&, s$
- With Sheet1
- n = .Cells(.Rows.Count, 1).End(xlUp).Row
- For i = 2 To n
- For j = 1 To .Cells(i, 2)
- s = s & .Cells(i, 1) & "-" & j & ","
- Next
- .Cells(i, 3) = Left(s, Len(s) - 1)
- s = ""
- Next
- End With
- End Sub
复制代码
|
|