Fill-Down Until Next Blank Cell

Hjalma

New Member
Joined
Apr 5, 2013
Messages
2
Can some of you gurus please solve my fill down issue. I've try to solve this few hours and now my brain hurts :)

I have lot of data in column B. I need to copy the first cell and paste content to next ones before empty cell.
Replacing xxx with the data in first cell all the way to the end of column B.

Before: After :

<tbody>
</tbody>

123-1123-1
xxx123-1
123-2123-2
xxx123-2
xxx123-2
321-1321-1
xxx321-1
xxx321-1
xxx321-1

<tbody>
</tbody>


Thanks.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
This works for me, however if you have a header row, you may want to change....

for i = 1 to lr

to have 1 be whatever the first row of the data is.

Code:
Sub FillItUp()

Dim lr As Long, i As Long
Dim Cell2Copy As String

lr = Range("A65536").End(xlUp).Row
For i = 1 To lr
    If Cells(i, "A") <> "xxx" And Cells(i, "A") <> "" Then
        Cell2Copy = Cells(i, "A").Value
    End If
    If Cells(i, "A") = "xxx" Then
        Cells(i, "A").Value = Cell2Copy
    End If
Next i

End Sub
 
Upvote 0
I don't know why there is a line between each data. Just give a try like this...

Select the range and Press Ctrl+G>>Special>>Blanks>>Ok>> Press = and Press Up Arrow and press Ctrl+Enter. then copy the range and paste it as values to convert the formula cells as valuees.
 
Upvote 0
Try something like this...

Code:
[color=darkblue]Sub[/color] Fill_Down()
    [color=darkblue]Dim[/color] rngArea [color=darkblue]As[/color] Range
    Application.ScreenUpdating = [color=darkblue]False[/color]
    [color=darkblue]For[/color] [color=darkblue]Each[/color] rngArea [color=darkblue]In[/color] Range("B:B").SpecialCells(xlCellTypeConstants).Areas
        rngArea.Value = rngArea(1).Value
    [color=darkblue]Next[/color]
    Application.ScreenUpdating = [color=darkblue]True[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
Hi
Suggested solutions totally solve my problemo.
Virtual drinks to everyone! (and real one if we ever meet :))
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,240
Members
448,555
Latest member
RobertJones1986

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