Suppose you have Excel data in the format
Row A
Row B
Row C
blank row
Row X
Row Y
Row Z
blank
I would like to 1) go to the row with the blank 2) copy the entire contents of the two rows above 3) paste the contents.
In the above example, the results would be
Row A
Row B
Row C
Row B
Row C
blank
Row X
Row Y
Row Z
Row Y
Row Z
blank
I am able to find the blanks. My code currently looks something like
Sub Find_Copy()
Dim rCell As Range
Dim r As Range
Dim r2 As Range
'We call the function and tell it to start the search in cell B1.
Set rCell = FindNextEmpty(Range("B8")) 'this is a separate function
'Shows a message box with the cell address. Right here is where
'you write the code that uses the empty cell.
rCell.Value = "Filled by macro 999"
MsgBox rCell.Address & " " & rCell.Value
rCell.Offset(-2, 0).EntireRow.Select 'dmt, select the row one above the blanks
Selection.Copy
Selection.Insert Shift:=xlDown
Set rCell = Nothing
End Sub
Can anyone help me get this sorted out? Thank you!