根据条件复制excel字段的块

我正在寻找一个快速的方式来填补一些基于以下条件的领域。 (见图)

我有一个包含3列的列表。 我需要根据列A中的字母来填充列C.当我到C34时,我想自动search上面的行,并根据列A中的字母复制上面最新发生的11个名称。 所以在C34-C44中,来自C1-C11的名称将被复制为一个块。

在Excel中有一个函数可以做到这一点?

数据截图在这里

您可以使用两个FOR循环的简单VBAmacros来解决您的问题:

Sub CompleteRows() Dim lastrow As Long lastrow = Cells(Rows.Count, "A").End(xlUp).Row 'finds last row in column A For x = 1 To lastrow 'loop that starts with value 1 and goes all the way to the value of lastrow If Cells(x, 3).Value = "" Then 'if value in column C is empty then continue on For y = 1 To lastrow 'second loop that runs through the same range If Cells(y, 1).Value = Cells(x, 1).Value And Cells(y, 2).Value = Cells(x, 2).Value Then 'If the value of the first column and the value of the second 'column for both values match, then add value to column C Cells(x, 3).Value = Cells(y, 3).Value Exit For 'Exit loop if value was found End If Next y End If Next x End Sub