Sub abc()
Dim rng As Range
Dim WSF As WorksheetFunction
Set rng = Range("A2")
Set WSF = WorksheetFunction
Do While rng <> ""
rng.Select
If WSF.CountIf(Range("A:A"), rng) < rng.Offset(0, 1) And rng.Offset(0, 1) > 1 Then
rng.Resize(columnsize:=2).Copy
rng.Resize(columnsize:=2, rowsize:=rng.Offset(0, 1) - 1).Insert shift:=xlShiftDown
End If
Set rng = rng.Offset(1, 0)
Loop
End Sub
vba不需要去筛选吧?只要根据B列值插入n-1行,写入数据即可