求助 公式
求助公式F3设常规格式:=LOOKUP(ROW(A1)-1,MMULT((ROW($1:$4)>COLUMN($A:$D))*1,C$3:C$6*D$3:D$6),B$3:B$6)&"-"&INT(COUNTIF(F$2:F2,LOOKUP(ROW(A1)-1,MMULT((ROW($1:$4)>COLUMN($A:$D))*1,C$3:C$6*D$3:D$6),B$3:B$6)&"-*")/LOOKUP(ROW(A1)-1,MMULT((ROW($1:$4)>COLUMN($A:$D))*1,C$3:C$6*D$3:D$6),D$3:D$6))+1&TEXT(MOD(COUNTIF(F$2:F2,LOOKUP(ROW(A1)-1,MMULT((ROW($1:$4)>COLUMN($A:$D))*1,C$3:C$6*D$3:D$6),B$3:B$6)&"-*"),LOOKUP(ROW(A1)-1,MMULT((ROW($1:$4)>COLUMN($A:$D))*1,C$3:C$6*D$3:D$6),D$3:D$6))+1,"-00")
下拉。 如果VBA处理的话会简单多了。 这个题目上个月就有人问了,用函数写局限性实在是太大了,公式写出来只能适用目前的数据而且繁琐复杂。
代码是非常简洁的,而且好理解。可以叫勇哥给你写个通用的代码 勇哥,能否给我 代码 来个 V BA 幢号总楼层单层套数
124 1-1-01
252 1-1-02
333 1-1-03 Private Sub CommandButton1_Click()
1-1-04 n = 3
1-2-01 Range("f3:f65536").ClearContents
1-2-02 For x = 3 To Range("b65536").End(xlUp).Row
1-2-03 For y = 1 To Cells(x, "c")
1-2-04 For z = 1 To Cells(x, "d")
2-1-01 Cells(n, "f") = Cells(x, "b") & "-" & y & "-" & Format(z, "00")
2-1-02 n = n + 1
2-2-01 Next
2-2-02 Next
2-3-01 Next
2-3-02 End Sub
2-4-01
2-4-02
2-5-01
2-5-02
3-1-01
3-1-02
3-1-03
3-2-01
3-2-02
3-2-03
3-3-01
3-3-02
3-3-03 感谢各位已解决 <blockquote>
Sub tex()
Dim i, j, k: n = 3
arr = Range("b2").CurrentRegion
For i = 2 To UBound(arr)
For j = 1 To arr(i, 2)
For k = 1 To arr(i, 3)
Range("f" & n) = arr(i, 1) & "—" & j & "—0" & k
n = n + 1
Next
Next
Next
End Sub