# Solved: Simple Excel Macro to Fill empty cells



## artcoder (Apr 7, 2009)

I'm trying to write an Excel macro that goes down a column. When it sees an empty cell, it should fill that cell in with the value of the cell that is just above it.

Thanks in advance.


----------



## MRdNk (Apr 7, 2007)

Welcome to the forums.

Can you paste your code, please?


----------



## Rollin_Again (Sep 4, 2003)

Try the code below. Just change the portions in red to represent your true starting cell (A1) and column letters (A)


```
Sub FillBlanks()

For Each vCell In Range("[B][COLOR="Red"]A1[/COLOR][/B]:[B][COLOR="red"]A[/COLOR][/B]" & Cells(Rows.Count, "[B][COLOR="red"]A[/COLOR][/B]").End(xlUp).Row).Cells

If vCell = "" Then

Range(vCell.Address).Value = Range(vCell.Address).Offset(-1, 0).Value

End If

Next vCell

End Sub
```
Regards,
Rollin


----------



## artcoder (Apr 7, 2009)

Thanks for the help.

I also found something similar (linked here) on the web.


----------



## Zack Barresse (Jul 25, 2004)

Why do you need code???

Select entire range
Hit F5
Click Special
Select Blanks, click OK
Type "=" (w/o quotes) then hit up arrow key
Confirm with Ctrl + Enter
(this next part assumes no formulas are in data range)
Select all data again
Copy (Ctrl + C)
Paste Values (Alt + E, S, V, Enter)

Voila. All by hand in < 5 seconds.

HTH


----------



## artcoder (Apr 7, 2009)

That manual method is a neat trick. I like it and it works. Thanks.


----------



## Zack Barresse (Jul 25, 2004)

You're very welcome. And btw, welcome to the board! 

You can mark your thread as Solved by clicking the Mark Solved button as well.


----------

