Fill Blanks From Below

blkmagik

New Member
Joined
Jun 25, 2008
Messages
34
Hello
I understand that the manual method for filling in blank cells from below
would be to:

  • Select the first blank cell
  • type = and hit the down arrow to creates the reference.
  • copy the cell, highlight the column
  • Edit - Go to - Special - Blanks and paste

I was curious if there is a macro that will allow me to do this all in one shot? I tried recording it but, it doesn't seem to record the process.

Ive found a macro but it doesn't loop and requires me to run it over and over again until it debugs and say no cells found.

Sub Fill_Blanks_From_Below()
Dim rng As Range, ar As Range
Set rng = Columns(1).SpecialCells(xlBlanks)
For Each ar In rng.Areas
ar.Value = ar.Offset(1, 0).Value
Next ar
End Sub

Thanks in advance.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
This macro will do what you have asked for...

Code:
Sub FillBlanksFromBelow()
  Dim A As Range
  On Error GoTo NoBlanks
  For Each A In Columns("A").SpecialCells(xlCellTypeBlanks).Areas
    A.FormulaR1C1 = "=R[1]C"
    A.Value = A.Value
  Next
NoBlanks:
End Sub
 
Upvote 0
Thank you so very much, appreciate your help and expertise
You are quite welcome. By the way, I have been thinking about your problem some more and came up with a slightly shorter, probably faster solution for you. Since we are talking about constant data in Column A, this code should also do what you want (notice... no loops).

Code:
Sub FillBlanksFromBelow()
  On Error GoTo NoBlanks
  With Range("A1").Resize(Cells(Rows.Count, "A").End(xlUp).Row)
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[1]C"
    .Cells.Value = .Cells.Value
  End With
NoBlanks:
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

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