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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

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,656
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

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

ManUBlueJay

Board Regular
Joined
Aug 30, 2012
Messages
222

ADVERTISEMENT

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

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
44,656
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,656
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,106,188
Messages
5,509,717
Members
408,750
Latest member
vdspharma

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top