Issue with Inserting a Row in a Table

Marhier

Board Regular
Joined
Feb 21, 2017
Messages
128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Afternoon everyone, I hope you're well.
Got a slight problem I'm trying to get my head around and was wondering if someone could help.

I've got a bit of code that goes to a named range, inserts a row and copies the format and formula from the row above:

Code:
Sub AddRowS1()
Application.ScreenUpdating = False
Call PaF_UnProtect
Application.Goto ("Section1")
Rows(Selection.Row - 1).Copy
Rows(Selection.Row).Insert Shift:=xlDown
Call PaF_Protect
Application.ScreenUpdating = True
End Sub

A fairly simple bit of code, which used to work, but due to wanting to have the data in column 'B' part of a Power Query so I can do a data validation without the blanks on another sheet, I've had to turn column B into a table.

Now when running the code, I get the following error message:

<a href="https://imgbb.com/"><img src="https://i.ibb.co/Sxf0DfL/02.png" alt="02" border="0"></a>

I was wondering if someone could help me amend the code so I can still insert a row and copy down from the row above, as when I do it manually, it works fine without an issue.

If it helps, my form looks as follows:



Any and all help is greatly appreciated.
Thank you.
Regards
Marhier
 
Last edited:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
See if this works for you:
Code:
Public Sub Add_Row_Above_Section1()
    Range("Section1").EntireRow.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("Section1").Offset(-2).EntireRow.Copy Range("Section1").Offset(-1).EntireRow
End Sub
 
Upvote 0
That worked a treat, John_w.
Thank you very much, sir!

Have a great day.

Regards
Marhier.
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,970
Members
448,933
Latest member
Bluedbw

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