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

…衆ロ難τιáo~ 提交于 2019-11-28 12:14:43

问题


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.


回答1:


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



回答2:


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'. 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.



来源:https://stackoverflow.com/questions/43211793/need-to-make-a-macro-in-excel-that-finds-blanks-in-a-column-and-then-fills-in-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!