Sub test() Dim s, X, m, i s = Range("A65536").End(xlUp).Row For i = 2 To s m = "" For X = 1 To Cells(i, 2) m = m & Cells(i, 1) & Format(X, "-000") & "," Next X m = Left(m, Len(m) - 1) Cells(i, 3) = m Next i End Sub本回答被提问者采纳
第2个回答 2015-05-04
用自定义函数。 1)插入一个模块,输入代码如下: Function GetReptString(strTitle As String, intRept As Integer) As String Dim I As Integer For I = 1 To intRept GetReptString = GetReptString & strTitle & "-" & Format(I, "000") If I < intRept Then GetReptString = GetReptString & "," Next End Function=GetReptString(A2,B2) 2)如A2=150430,B2=8,C2=GetReptString(A2,B2)本回答被网友采纳