简体   繁体   English

需要在excel中创建一个宏,该宏在列中查找空白,然后从空白单元格上方填充值。 随附图片以说明

[英]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! 谢谢!

Picture to illustrate. 图片说明。

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.

相关问题 EXCEL:用上述值填充空白单元格除以空白数 - EXCEL: Fill blank cells with above value divided by number of blanks VBA Excel-自动运行宏以在上面的单元格输入值后插入新的空白行 - VBA Excel - Auto run macro to insert new blank row after cell above has value entered 在单元格中输入特定值时,使用vlookup的VBA宏。 需要为整个专栏工作 - VBA macro using vlookup when a certain value is entered in cell. Needs to work for an entire column Excel在同一列中向所有人发送电子邮件,只需要向特定单元格中的所有人发送电子邮件。 怎么样? - Excel sending emails to all people in one Column, need to email only person in specific cell. How? 如果值> 1,则在下面插入空白单元格的宏,并从上面的单元格复制/粘贴值 - Macro to insert blank cells below if value >1 and copy/paste values from cell above 在 Excel 检查两个单元格中的短语,如果在两个单元格中找到任何列出的单词,则需要在另一个单元格中添加该单词。 对整列重复此操作 - In Excel Check phrases in two cell and in the two cell if any listed word found,need to add the word in another cell. repeat this for entire column Excel宏或函数:如果单元格不为空,则使用循环值(来自另一张纸)填充单元格区域(A列) - Excel Macro or Function: Populate a cell range (Column A) with a looped values (from another sheet) if cell is not blank 在Excel上方和下方的列中填充空白 - Fill blanks in a column in Excel above and below Excel:如果单元格中的值与另一个选项卡上的列中的值匹配,我如何返回空白行上方的特定单元格? - Excel: If a value in a cell matches a value in a column on another tab, how can I return a specific cell above a blank row? 以编程方式找到匹配单元格的Excel宏 - Excel Macro That Programmatically finds a matching cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM