如何在Excel中复制不同的行?
我在“广告组”列中有单个值,需要在下面的行中的空白单元格中进行复制。 每个广告组名称应该有3个。
我的第一个截图显示了它目前是如何:
我的第二个屏幕截图显示了我需要它:
有30k行,所以我需要一个公式或dynamic的方式来实现这一点。
这是我的答案:
使用VBA:
Sub selectBlankCells() Dim r 'to store the number of the last row of data Dim rng As Range r = Range("A1").End(xlDown).Row 'to find the last row Set rng = Range(Cells(1, 2), Cells(r, 2)) ' set the range of column B, of the data rng.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C" ' this is where you put the formula to 'set the data of above cell in every empty cell of 'column B End Sub
或者你可以使用Excel选项:
select列B的数据,从最后一行到单元格B1,然后按F5
,此窗口出现。
然后按Special...
之后,selectBlanks
然后OK
您将只select空白单元格,然后您可以将公式从活动单元格链接上述单元格。
这样使用([Ctrl] + [Enter]将公式放入所有的单元格中,就像Jeeped所说的那样):
你会得到这个: