VBA的答案(它给你它在你之后的确切格式)如下:
Sub DigitBlocks()
Dim rng As Range, a As Double, b As Double, c As Double, d As Double, e As Double
Set rng = ActiveSheet.Range("A2").CurrentRegion
a = Val(Right(Left(rng.Address, InStr(rng.Address, ":") - 1), Len(Left(rng.Address, InStr(rng.Address, ":") - 1)) - InStrRev(Left(rng.Address, InStr(rng.Address, ":") - 1), "$"))) + 1
b = 3
For d = a To rng.Rows.Count
Range("E" & b).Value = Range("A" & d).Value
e = Range("B" & d).Value
For c = 1 To e
Range("F" & b + c - 1).Value = c
Next c
b = b + c
Next d
End Sub
鉴于意见修订后的要求,答案是现在:
Sub DigitBlocks()
Dim rng As Range, a As Double, b As Double, c As Double, d As Double, e As Double
Set rng = ActiveSheet.Range("A2").CurrentRegion
a = Val(Right(Left(rng.Address, InStr(rng.Address, ":") - 1), Len(Left(rng.Address, InStr(rng.Address, ":") - 1)) - InStrRev(Left(rng.Address, InStr(rng.Address, ":") - 1), "$"))) + 1
b = 3
For d = a To rng.Rows.Count
Range("M" & b).Value = Range("J" & d).Value
e = Range("K" & d).Value
For c = 1 To e
Range("N" & b + c - 1).Value = c
Next c
b = b + c
Next d
End Sub
在VBA中应该很容易。这是一个选择吗? –
视觉基础我可以得到是的。但不知道如何。并将它仍然出口到Excel格式? –
是的,您只需循环查看A和B列中的内容,然后为E&F添加值即可。它将位于同一个Excel文件中。 –