[英]Need to make a macro in excel that finds blanks in a column, and then fills in the value from above the blank cell. Picture included to illustrate
So I have a column with blanks randomly throughout...I need a macro that would select only the blanks, and then in those blank cells paste in the value of the cell above it. 所以我有一整列随机有空白的列...我需要一个仅选择空白的宏,然后在这些空白单元格中粘贴其上方单元格的值。 The select part is obviously easy, but I keep getting errors about 'too many continuations' when trying to fill the formula down into the blanks.
选择部分显然很容易,但是当尝试将公式填充为空白时,我总是收到关于“太多延续”的错误。 I included a picture, the first column is a 'before' and the second is how I want the column to look after the application of the macro.
我包括了一张图片,第一列是“之前”,第二列是我希望该列在应用宏之后的外观。
If the macro needs to create a second column or something that's fine too, as long as the end result looks like it does in the picture. 如果宏需要创建第二列或也可以的东西,只要最终结果看起来像图片中那样。 Thanks!
谢谢!
try, 尝试,
sub fillblankfromabove()
dim blnks as range
with worksheets("Sheet1").Columns("E").Cells
set blnks = .specialcells(xlcelltypeblanks)
if not blnks is nothing then
blnks.formular1c1 = "=r[-1]c"
end if
.value = .value
end with
end sub
Another way to do this is to select all cells that you want included in this process, press CTRL + G, select Special, then select 'Blank Cells'. 另一种方法是选择要包含在此过程中的所有单元格,按CTRL + G,选择“特殊”,然后选择“空白单元格”。 This will select all blank cells within your selected range.
这将选择您所选范围内的所有空白单元格。 Then enter
=[cell above]
and press CTRL + ENTER and it will enter that formula into all selected cells. 然后输入
=[cell above]
,然后按CTRL + ENTER,它将在所有选定的单元格中输入该公式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.