Macro to fill to next field with data
This is something similar (as I understand it). I have some users
who, after manipulating copies of pivot tables, want to fill the empty
cells under each grouping. I welcome any critique to this approach
Sub Copy_down2()
'Copy cell above to current cell and empty cells below
' make the range wider by adjusting the column offset, where 0 =
current
Dim rng_frm As Range, rng_to As Range, intCO As Integer, intLC As Long
intCO = 0 ' column offset
intLC = ActiveSheet.Rows.Count
Do While ActiveCell.Row < intLC
If IsEmpty(ActiveCell) Then
Set rng_frm = Range(Cells(ActiveCell.Row - 1,
ActiveCell.Column).Address _
& ":" & Cells(ActiveCell.Row - 1, ActiveCell.Column +
intCO).Address)
Set rng_to = Range(Cells(ActiveCell.Row,
ActiveCell.Column).Address _
& ":" & IIf(IsEmpty(ActiveCell(2)), (Cells
(ActiveCell.End(xlDown).Row - 1, ActiveCell.Column).Address), (Cells
(ActiveCell.Row, ActiveCell.Column).Address)))
rng_frm.Copy rng_to
Cells(ActiveCell.End(xlDown).Row,
ActiveCell.Column).Select
End If
ActiveCell(2).Select
If ActiveCell.End(xlDown).Row = intLC Then
Exit Sub
End If
Loop
End Sub
|