Delete Row from Table

ManUBlueJay

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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

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,215
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
224

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

ManUBlueJay

Board Regular
Joined
Aug 30, 2012
Messages
224

ADVERTISEMENT

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

Fluff

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

Watch MrExcel Video

Forum statistics

Threads
1,108,855
Messages
5,525,227
Members
409,637
Latest member
LT TASL

This Week's Hot Topics

Top