Delete Row from Table

ManUBlueJay

Board Regular
Joined
Aug 30, 2012
Messages
222
I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell.
In the past I have used this simple code "Range("MyRange").EntireRow.Delete"

This does not work today in Excel 2016
 

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

KOKOSEK

Board Regular
Joined
Apr 8, 2019
Messages
226
Office Version
365, 2013
Platform
Windows
Code:
Rows(MyRange.Row).EntireRow.Delete
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
44,521
Office Version
365
Platform
Windows
In what way doesn't the code in your op work?
 

ManUBlueJay

Board Regular
Joined
Aug 30, 2012
Messages
222
I just ran a simple macro with only this line

VBA Code:
Sub Test()
Rows(MyRange.Row).EntireRow.Delete
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
44,521
Office Version
365
Platform
Windows
I was referring to the code you posted.
 

ManUBlueJay

Board Regular
Joined
Aug 30, 2012
Messages
222
I get a Run Time Error 1004 "Delete method of Range class failed"
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
44,521
Office Version
365
Platform
Windows
Is MyRange a named range or is it a variable that you have declared in the macro?
 

ManUBlueJay

Board Regular
Joined
Aug 30, 2012
Messages
222
It is a named range. My formula finds the right cell to delete. The table is 8 Cols wide.
The Table is called "MyTable"
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
44,521
Office Version
365
Platform
Windows
What does this return
VBA Code:
MsgBox Range("myrange").Address
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,105,964
Messages
5,508,429
Members
408,685
Latest member
kyrendaniel

This Week's Hot Topics

Top