If the cell is empty, copy the value from a specific cell.

  • Thread starter Thread starter Aline
  • Start date Start date
A

Aline

Hi there,

How do I write a macro that will check the cells to see if they are empty.
If the cell J3 is empty, if it will copy the content from J2 onto J3. Do the
same for J4, J5... J8.

Thanks,
Aline
 
I think this will do what you want...

Sub FillOutTheColumn()
Dim Area As Range, LastRow As Long
On Error Resume Next
LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
For Each Area In Range("J2:J" & LastRow). _
SpecialCells(xlCellTypeBlanks).Areas
Area.Value = Area(1).Offset(-1).Value
Next
End Sub
 
Back
Top