Delete Row from Table

ManUBlueJay

Board Regular
Joined
Aug 30, 2012
Messages
226
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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

KOKOSEK

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

Fluff

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

ManUBlueJay

Board Regular
Joined
Aug 30, 2012
Messages
226

ADVERTISEMENT

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
46,474
Office Version
  1. 365
Platform
  1. Windows
I was referring to the code you posted.
 

ManUBlueJay

Board Regular
Joined
Aug 30, 2012
Messages
226

ADVERTISEMENT

I get a Run Time Error 1004 "Delete method of Range class failed"
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,474
Office Version
  1. 365
Platform
  1. 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
226
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
46,474
Office Version
  1. 365
Platform
  1. Windows
What does this return
VBA Code:
MsgBox Range("myrange").Address
 

Watch MrExcel Video

Forum statistics

Threads
1,109,259
Messages
5,527,671
Members
409,781
Latest member
Maxcwy2020

This Week's Hot Topics

Top