Fill or copy cell if blank

JAYLO

Board Regular
Joined
Apr 3, 2002
Messages
238
Looking for a way to walk down a column and, if a cell is blank copy the contents of the cell above and keep going.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Looking for a way to walk down a column and, if a cell is blank copy the contents of the cell above and keep going.



Code:
Columns("A:A").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.FormulaR1C1 = "=R[-1]C"
 
Upvote 0
Hi,

Try:

Code:
Sub test()
    lRow = Range("A65536").End(xlUp).Row
    
    For i = 2 To lRow
        If Cells(i, 1).Value = "" Then Cells(i, 1).Value = Cells(i - 1, 1).Value
    Next
End Sub

Change Cells(i,1) to the column you want (B is 2, C is 3 etc).
 
Upvote 0
Highlight the column
Click Edit - Goto - Special - Blanks - OK
Press =
Press UP Arrow
Press CTRL + ENTER

Now you have formulas where there used to be blanks.
If you want to remove the formulas and leave the values

Highlight the column
Right click - Copy
Right click - Paste Special - Values - OK


Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,224,538
Messages
6,179,412
Members
452,912
Latest member
alicemil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top