PDA

View Full Version : How to fill down to a certain length and delete everything before it



anne.gomes
05-26-2014, 03:32 PM
Hi,

So I want to fill down content from previous cell in column B and paste it to the length of data in column C. And then I want to delete all the previous content in column B right up until what I just pasted.

I have this code so far which copys and fills down right to the bottom. I now need to add length to it and also to delete all the previous content in the same column that I just copied and filled down from.




Sub FillCellsFromAbove()
Application.ScreenUpdating = False
On Error Resume Next
With Columns(2)
.SpecialCells(xlCellTypeBlanks).Formula = "=R[-1]C"
.Value = .Value
End With
Err.Clear
Application.ScreenUpdating = True
End Sub




Please help i am fully lost on how to do this....

Thanks so much in advance! Sorry if I was confusing.

jolivanes
05-26-2014, 10:14 PM
Is this what you mean.
Try it on a copy of your original, just in case!!!!

Sub Maybe()
Dim lr As Long
lr = Cells(Rows.Count, 2).End(xlUp).Row
Cells(lr, 2).Copy Range(Cells(lr + 1, 2), Cells(Cells(Rows.Count, 3).End(xlUp).Row, 2))
Range("B1:B" & lr).ClearContents
End Sub

mancubus
05-27-2014, 12:21 PM
hi.
try this.



Sub FillCellsFromAbove()

Application.ScreenUpdating = False

On Error Resume Next
With Range("B2:B" & Range("C" & Rows.Count).End(xlUp).Row)
.SpecialCells(xlCellTypeBlanks).Formula = "=R[-1]C"
.Value = .Value
End With

Application.ScreenUpdating = True

End Sub

anne.gomes
05-27-2014, 04:00 PM
Thanks so much guys! you guys are life savers!!! :)