PDA

View Full Version : Fill Down Automatically?



sunkitty356
03-13-2007, 08:10 AM
I need to fill in values (in same column) as in this example
so that 7533 would be filled down to the next cell containing text.
This is the same as selecting the cell containing and down, then pressing ctl+D, except I want a more automated command or macro to do this.
Seems easy....can it be done? Thanks!

A 7533

B

C

D 6588

E

Bob Phillips
03-13-2007, 08:37 AM
This should do it



Dim iLastRow As Long
Dim iNext As Long
Dim i As Long

With ActiveSheet

i = 1
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Do Until i >= iLastRow
iNext = .Cells(i, "A").End(xlDown).Offset(-1).Row
.Cells(i, "A").AutoFill .Cells(i, "A").Resize(iNext - i + 1)
i = iNext + 1
Loop
End With

sunkitty356
03-13-2007, 09:52 AM
:friends: Thank you

mdmackillop
03-13-2007, 12:05 PM
Hi SunKitty,
If this is solved, you can mark it so using the Thread Tools drop-down