我在B栏中有一些名字,在C栏中有一些数字。
我想在D栏中打印B次C:
B : John | Bob | Steeve
C : 4 | 0 | 2
D : John | John | John | John | Steeve | Steeve
我目前在B列中使用以下公式列出列表A中有空白的元素。
=IFERROR(INDEX($A$2:$A$200,SMALL(IF(LEN($A$2:$A$200)>0,ROW($A$2:$A$200)-ROW($A$200)),ROW(2:2)),1),"")
答案 0 :(得分:0)
尝试使用此宏来填充D
列:
Sub FillD()
Dim colB As Range, b As Range, d As Range, c As Integer
With Worksheets("Sheet1") ' <-- your sheet's name here
Set colB = .Range("B2:B" & .Cells(.Rows.Count, "B").End(xlUp).Row)
Set d = .Range("D2")
End With
For Each b In colB
c = b.Offset(, 1).Value
If c > 0 Then
d.Resize(c, 1).Value = b.Value
Set d = d.Offset(c)
End If
Next
End Sub