Want to insert rows in the middle of a table by pushing down rows below.

Joined
Dec 21, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi,

I want to copy a fixed range of cells to the location of the active cell with the cell and row properties. I have that part working as below but I want to by able to insert it into the middle of a sheet and push down the rows below so that they don't get overwritten. Can anyone help with this please?

VBA Code:
Sub POInsert()
Dim btn As OLEObject, x As Long, y As Long, i As Long
Application.ScreenUpdating = False
y = ActiveCell.Row
Range("A1:M6").Copy Destination:=Cells(y, 1)


For i = 0 To 6
    Rows(y + i).RowHeight = Rows(1 + i).RowHeight
Next i
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
You have the copy statement. Just remove the "Destination" and use an "Insert" instead.:
VBA Code:
Range("A1:M6").Copy 'Destination:=Cells(y, 1)
Cells(y, 1).Insert xlShiftDown
 
Upvote 0
Solution

Forum statistics

Threads
1,215,087
Messages
6,123,046
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top