如何find第一个空白单元格后,使用VBA向下拖动(自动填充)公式
我需要一些帮助拖动一个string(“Decliners”)在Excel中的列。 我知道怎么做,如果我知道什么细胞是我的出发点,但我首先必须find我的数据集中的第一个空行。
一旦find我的第一个空白行,我需要从列C3中拖动我的string。
这个string正被拖到一列。 我也不知道这个数据集的范围,因为它是dynamic的。
本质上,我只需要重新创build双击单元格右下angular的动作,单词“Decliners”填充到数据集的底部。
代码来select工作表中的第一个空白单元格:
Dim Pastesheet As Worksheet Dim Decliners As String Decliners = "Decliners" Set Pastesheet = Worksheets("Ent Gainers_Decliners") Pastesheet.Range("C3").End(xlDown).Offset(1, 0).Select 'Where I need the word "Decliners" dragged down from the cell selected
With Pastesheet .Range(.Range("C3").End(xlDown).Offset(1),.Cells(.Rows.Count,4).End(xlUp).Offset(,-1)).Value = Decliners End With
这段代码将设置variablesDecliners
的值从最后一个范围C3
的最后一个数据集,直到C3
列的最后一个相应的使用数据行。