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文件中。 –