View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default VBA to autofill next blank cell in same column

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


--
Gary''s Student - gsnu200747


"manfareed" wrote:

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

"Gary''s Student" wrote:

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.
--
Gary''s Student - gsnu200747


"manfareed" wrote:

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