VBA to autofill next blank cell in same column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi ,

I have data in column A in sa "A2". If "A3" is blank then I want to copy the
value from "A2". Next I would expect the macro to go to the next populated
cell in column A eg. "A4" and copy "A4" to "A5" and so forth.

Thanks,

Manir
 
Sub ABC()
set rng = cells(rows.count,1).End(xlup)
rng.offset(1,0).Filldown
End Sub
 
Sub fill_er_up()
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To n
If IsEmpty(Cells(i, 1)) Then
Cells(i, 1).Value = Cells(i - 1, 1).Value
End If
Next
End Sub

this is coded for column A, can be modified for any column.
 
Hi,

It works but how do I ensure that it is the same format as the line above
i.e. font colour etc.

Thanks,

Manir
 
Sub ABC()
Dim rng As Range, ar As Range
Set rng = Columns(1).SpecialCells(xlBlanks)
For Each ar In rng.Areas
ar(0).Copy ar
Next
End Sub
 
Sub fill_er_up2()
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To n
If IsEmpty(Cells(i, 1)) Then
Cells(i, 1).FillDown
End If
Next
End Sub
 
Excellent ...

Thanks

Tom Ogilvy said:
Sub ABC()
Dim rng As Range, ar As Range
Set rng = Columns(1).SpecialCells(xlBlanks)
For Each ar In rng.Areas
ar(0).Copy ar
Next
End Sub
 
Many Thanks ...

Gary''s Student said:
Sub fill_er_up2()
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To n
If IsEmpty(Cells(i, 1)) Then
Cells(i, 1).FillDown
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top