excel vba insert a range and shift cells down code example
Example: excel vba shift range
Function ShiftRange(ByVal pRange As Range, ByVal pRowOffset, ByVal pColumnOffset)
Set ShiftRange = pRange.Offset(pRowOffset, pColumnOffset)
End Function
Sub TestIt()
Dim rInitialRange, rShiftedRange As Range
Dim iRowOffset, iColOffset As Long
iRowOffset = 2
iColOffset = -1
Set rInitialRange = Range("D1:B3")
Set rShiftedRange = ShiftRange(rInitialRange, iRowOffset, iColOffset)
MsgBox "Initial range: " & rInitialRange.Address(False, False) & vbCrLf _
& vbCrLf & "Row offset : " & iRowOffset _
& vbCrLf & "Column offset : " & iColOffset & vbCrLf _
& vbCrLf & "New range : " & rShiftedRange.Address(False, False)
End Sub